0

ZK Desktop

asked 2011-04-18 05:18:53 +0800

arctrev gravatar image arctrev
30 1

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

delete flag offensive retag edit

8 Replies

Sort by ยป oldest newest

answered 2011-04-18 20:55:54 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

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

link publish delete flag offensive edit

answered 2011-04-18 22:02:57 +0800

arctrev gravatar image arctrev
30 1

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

link publish delete flag offensive edit

answered 2011-04-19 00:11:59 +0800

arctrev gravatar image arctrev
30 1

found old thread that discuss similiar problem
http://www.zkoss.org/forum/listComment/4705;jsessionid=47157BD3429F2EE4042B4A27A4B769C4.zkzh
but no solution.. :(

link publish delete flag offensive edit

answered 2011-04-19 00:25:16 +0800

arctrev gravatar image arctrev
30 1

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

link publish delete flag offensive edit

answered 2011-04-19 01:51:30 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

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.

link publish delete flag offensive edit

answered 2011-04-19 04:10:06 +0800

arctrev gravatar image arctrev
30 1

ok, i will think another work around for this problem, using desktop wasn't a good choice i guess
thanks for your help

link publish delete flag offensive edit

answered 2011-07-12 11:16:08 +0800

zippy gravatar image zippy
504 1 2

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>

link publish delete flag offensive edit

answered 2013-09-20 21:51:16 +0800

sebon gravatar image sebon
1 1

hi, I have the same problem. I was read in this fotum that the solution is use a cache for desktop put a listener: "DesktopRecycle" in your zk.xml

in my case dont work fine.

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
2 followers

RSS

Stats

Asked: 2011-04-18 05:18:53 +0800

Seen: 1,121 times

Last updated: Sep 20 '13

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