-
FEATURED COMPONENTS
First time here? Check out the FAQ!
This is a by-product of the issues on the Ipad where the ZK desktop cleanup does not happen since the webkit on the Ipad is not triggering the necessary javascript for ZK.
I am trying to manually cleanup the previous desktop when the user moves to a new page, unfortunately, when I call desktop.invalidate() I am getting nullpointer exceptions.
This code is executed when a new desktop is created (registered as a desktopinit listener), I have stored the previous desktop in the session and retrieve it so I can manually do cleanup when being accessed from the ipad. The call is not necessary from a PC since cleanup gets called normally through ZK.
public void init(Desktop desktop, Object arg1) throws Exception { Session session = desktop.getSession(); String browserType = (String)session.getAttribute(DHnPageArguments.browsertype.toString()); // If we are on the Ipad, a new desktop being created means that we have gone to a new screen. // The old desktop should be cleaned up automatically by ZK, but since it does not get the correct javascript call // from the Ipad - it never happens. // This code will check to see if we are on the Ipad and there is an old Desktop - call proxy cleanup // manually. if ((browserType != null) && (browserType.contains(DHnPageArguments.iPad.toString()))) { Desktop oldDesktop = (Desktop)session.getAttribute("desktop"); session.setAttribute("desktop",desktop); if (oldDesktop != null) { cleanupOldIpadDesktop(oldDesktop); oldDesktop.invalidate(); } } And here is the exception which is thrown on oldDesktop.invalidate();
}
Hi ansancle,
The 'invalidate' denotes to rerender/redraw the old desktop, it is better do not redraw the old desktop after it is cleaned up.
Regards,
Ben
Hi Andy,
Please refer to the document:
ZK_Developer's_Reference/Customization/Init_and_Cleanup
ZK will clean up desktop automatically if the number of desktop hits the limitation 'max-desktops-per-session' in session config or idle time of desktop hits the 'desktop-timeout' in desktop-config, the 'cleanup' here is to clean some specific extra data.
For example, assume you have the fragment when init:
dataMap.put(userId, usersHugeData);
then you may want remove it while desktop cleanup
if (isLoggedOut(userId)) dataMap.remove(userId);
For more information, please refer to
ZK Configuration Reference/zk.xml/The session-config Element
ZK Configuration Reference/zk.xml/The desktop-config Element
Edit:
If you really want to remove a desktop manually, you may try something like below:
<zk> <button label="test"> <attribute name="onClick"> Desktop dt = self.getDesktop(); WebApp wapp = dt.getWebApp(); System.out.println(dt); System.out.println(wapp); ((org.zkoss.zk.ui.sys.WebAppCtrl)wapp).getDesktopCache(dt.getSession()).removeDesktop(dt); </attribute> </button> </zk>
However, it is Strongly recommended NOT to do this.
Regards,
Ben
Ben,
thanks for the information on how to finally do it. I am familiar with all of the timeout settings and may go back to setting a very large timeout (greater than my page timeouts), so when it's access from the Ipad they will get cleaned up.
Thanks again!!
Andy
Asked: 2012-06-25 12:24:44 +0800
Seen: 227 times
Last updated: Jul 12 '12