-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi all
I have problem understanding zk's Desktop, i have these two scenarios:
first :
1. if i open my app in new browser or tab, zk will create new Desktop (let say Desktop ABC) for this new app
2. if I check ABC.isAlive(), the value would be TRUE by now
3. and if i close that tab or browser, zk will destroy the Desktop (ABC)
4. if I check ABC.isAlive(), the value would be FALSE by now
no problem with this scenario
second:
1. I open my app in a browser or tab, zk create new Desktop again (let say Desktop XYZ)
2. If i check XYZ.isAlive(), the value would be TRUE by now
3. now I press F5 to refresh this browser or tab, zk will create new Desktop again (let say Desktop JKL)
4. if I check XYZ.isAlive, the value is TRUE...
should it be destroyed by now? why the value still TRUE?
5. now i close my browser or tab (please notice that active desktop now is Desktop JKL)
6. if I check JKL.isAlive, the value is FALSE
this is correct
7. but if I check XYZ.isAlive, the value still TRUE...
can someone explain to me how zk's Desktop work?
here is the code to try my problem
public zkNewProject() { List<Desktop> deskIDs = (List<Desktop>) Sessions.getCurrent().getWebApp().getAttribute("TEMP"); if(deskIDs==null) { deskIDs = new ArrayList<Desktop>(); } deskIDs.add(Executions.getCurrent().getDesktop()); Sessions.getCurrent().getWebApp().setAttribute("TEMP",deskIDs); System.out.println("--------------------"); for (int i = 0; i < deskIDs.size(); i++) { System.out.println(deskIDs.get(i)+" - "+ (deskIDs.get(i).isAlive() ? "Alive" : "Dead")); } System.out.println("--------------------"); }
Thanks in advance,
Arc
the desktop is destroyed by a browser event(as i remember, onunload), just like other ajax request, and in some browser and situation it will not send that event.
so zk have now way to know to destroy the desktop(same case as lose network connection, pc power off)
however, zk have max desktop number and desktop timeout to prevent the leak of memory
Aah... so i guess i have the wrong perception about the desktop.
After read your post, i tried with different browser, and the result is different between them (IE same as Firefox, Chrome has different result)
Actually, what i want to do is lock a file with the desktop, so when someone open a file, other user can't open this file (i put the desktop id as stamp in the file),
so as long the file has desktop id stamp inside it, this file can only be opened by the desktop that has the same id.
but if the desktop is destroyed (as result of user close the browser or browser crash), another user can open this file (since the desktop id inside the file isn't exist anymore)
alas this method can't work if the user refresh the page (F5 or hit the URL).
Any idea for this problem?
Thanks
found old thread that discuss similiar problem
http://www.zkoss.org/forum/listComment/4705;jsessionid=47157BD3429F2EE4042B4A27A4B769C4.zkzh
but no solution.. :(
quote from http://www.zkoss.org/javadoc/latest/zk/org/zkoss/zk/ui/util/DesktopCleanup.html
"2.Then, each time ZK loader is destroying a desktop, an instnace of the specified class is instantiated and cleanup(org.zkoss.zk.ui.Desktop) is called."
does it means that zk know when to destroy a desktop?
if yes then when or what event cause zk loader destroy the desktop?
thanks
there is no way to grantee to destroyed a desktop just when an user close the browser (or tab, or F5).
as I said, the network could be disconnected by any reason, a pc could be powered off without notification to browser to ZK.
so ZK can just grantee to destroy a desktop if.
1.the browser sent onunload.
2.the desktop timeout
3.the maximum desktop number reached.
maybe you can set the desktop time shorter and use timer to keep desktop alive to archive.
but I have no perfect idea to solve it. it is http/browser limitation.
up!!
i have a issue , i use zk monitor to control the performance and i got this:
Version: 5.0.7
Build: 2011051111
What
Total
Hourly Average
Active
Number of Sessions
21
0.08
-3
Number of Desktops
58
0.23
5
Number of Updates
3,514
13.65
1
Serving since Fri Jul 01 18:47:47 CLT 2011
Now is Tue Jul 12 12:14:03 CLT 2011
Time escaped 257 hours 26 mins
The number of desktop worried me , the zk.xml says:
<session-config> <device-type>ajax</device-type> <automatic-timeout/> <!-- the same as <automatic-timeout>true</automatic-timeout> --> <timeout-uri>/login.zul</timeout-uri> <session-timeout>600</session-timeout> <timer-keep-alive>false</timer-keep-alive> <max-desktops-per-session>3</max-desktops-per-session> <max-requests-per-session>6</max-requests-per-session> <max-pushes-per-session>5</max-pushes-per-session> </session-config>
Asked: 2011-04-18 05:18:53 +0800
Seen: 1,121 times
Last updated: Sep 20 '13