0

how to keep components state when browser refresh

asked 2009-11-28 23:03:37 +0800

likebean gravatar image likebean
39 2

Any method not recreate the desktop,page and components when refresh browser,and only retrieve the existed Page Object and redraw?I debug DHtmlLayoutServlet,find when refresh Browser,DHtmlLayoutServlet will create new Desktop and Page and Components each time,old Object seems be discard.(I want to use zk in my portal environment to develop portlet,In the portal page,there maybe other portlet not develop using ajax technology,so operation in non-ajax-portlet may result in whole portal page refresh.so how can I keep the component state of the zk-portlet)

I am confused about the concept:Desktop and Page,ZK document say Desktop may contain many pages,what 's meaning?any example about one desktop contain many pages?what's relationship about URL,Desktop and Page?

delete flag offensive retag edit

7 Replies

Sort by ยป oldest newest

answered 2009-11-29 19:27:54 +0800

joylo0122 gravatar image joylo0122
688 1
www.zkoss.org

updated 2009-11-29 19:29:18 +0800

@likebean

Hi likebean, as you see, if you refresh browser, we will create new Desktop & Components.
I'm afraid to inform you that we don't have any method to stop this unless you edited the codes.

And here is a example about pages in the same desktop.
In zul

<zk>
<page>
...
</page>

<page>
...
</page>
</zk>

You can put any components between the page start tag and the end tag.

/Joy

link publish delete flag offensive edit

answered 2009-11-29 19:56:41 +0800

likebean gravatar image likebean
39 2

Can this feature add in ZK 5.0?because I think serverside executing is the most different and advantage when compare ZK with other ajax-web framework like GWT.If not only using ajax style but also keeping components state when refreshing browser,It's cool,and will be great feature of ZK!

L.J.W

link publish delete flag offensive edit

answered 2009-11-29 20:04:50 +0800

joylo0122 gravatar image joylo0122
688 1
www.zkoss.org

@likebean

Of cause yes, you can post here. If that is a correct way and lot of people need it, we should have some change for it.

Thanks for your suggestion.

/Joy

link publish delete flag offensive edit

answered 2009-11-30 08:29:02 +0800

likebean gravatar image likebean
39 2

Hi joylo,has post feature request,wish get a result quickly...Thanks.

link publish delete flag offensive edit

answered 2009-11-30 22:04:53 +0800

likebean gravatar image likebean
39 2

Hi joylo,I try to keep id of Desktop and Page Object in Session,when refresh browser,I retrieve Desktop and Page Object throught these id, and reimplement UiEngine execNewPage0 method,not recreate page and components,and invoke code of Cycle 3: Generate output directly,now I refresh browser,page and components state keep,but I found a ajax requst /zkau?dtid=g4nh&cmd_0=rmDesktop send to server immediately,so when I refersh browser again,Desktop could not be retrieve again..Why and how?

Best rgds

L.J.W

link publish delete flag offensive edit

answered 2010-01-05 15:51:12 +0800

htang gravatar image htang
3

updated 2010-01-05 16:00:27 +0800

You may feel interested to read about this option: keep-across-visits.

By specifying this option, the desktop will not be removed automaticaly on the server side when the HTML page is unloaded (and then reloaded). However, by doing so, you should also consider when to actually remove desktops that no long being used by the clients. Otherwise, your server memory will be overwhelmed by useless desktop very soon. There is a max-desktop-per-session counter, so it shall not crash your system. It will still use much more memory: by default, up to 20 times more (as max-desktop-per-session = 20).

link publish delete flag offensive edit

answered 2012-07-24 06:57:50 +0800

mail2anish gravatar image mail2anish
6

You can use the DesktopRecycle approach here.
Create a class which implements org.zkoss.zk.ui.util.DesktopRecycle
in beforeRemove method push the desktop object to the session.

in beforeService method pull the deskop from the session and return.

in afterService is the session doesn't have the deskop object, push the desktop to session.

in ZK.xml file add this above class as a listener.

You should be all set.. with this when you refresh the browser, the UI state would retain as it was before refresh.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-11-28 23:03:37 +0800

Seen: 1,940 times

Last updated: Jul 24 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More