Reuse Desktops
This documentation is for an older version of ZK. For the latest one, please click here.
[Since 5.0.0]
By default, a desktop is purged when the user browses to another URI or refreshes the page. Thus, the user can have the most updated information. However, if a page takes too long to generate, you can provide a plugin so-called desktop recycle.
First, you implement the DesktopRecycle interface to cache and reuse the desktops which are supposedly being removed. Second, specify the class in WEB-INF/zk.xml. For example, let us assume the class you implement is called foo.MyRecycle, then add the following to zk.xml
<listener>
<listener-class>foo.MyRecycle</listener-class>
</listener>
org.zkoss.zkmax.zk.ui.util.DesktopRecycle
[Enterprise Edition] [Since 5.0.0]
ZK provides a default implementation, the , and re-generate the page if it has been served for more than 5 minutes.
public class MyRecycle extends org.zkoss.zkmax.zk.ui.util.DesktopRecycle {
protected boolean shallCache(Desktop desktop, String path, int cause) { return path.startsWith("/long-op"); } protected boolean shallReuse(Desktop desktop, String path, int secElapsed) { return secElapsed >= 300; }
}
=== Implement Your Own Desktop Recycle ===
[Since 5.0.0]
It is straightforward to implement the
For example, we can limit the URL to cache to "/long-op/*"
, and re-generate the page if it has been served for more than 5 minutes.
public class MyRecycle extends org.zkoss.zkmax.zk.ui.util.DesktopRecycle {
protected boolean shallCache(Desktop desktop, String path, int cause) { return path.startsWith("/long-op"); } protected boolean shallReuse(Desktop desktop, String path, int secElapsed) { return secElapsed >= 300; }
}
=== Implement Your Own Desktop Recycle ===
[Since 5.0.0]
It is straightforward to implement the
For example, we can limit the URL to cache to "/long-op/*"
, and re-generate the page if it has been served for more than 5 minutes.
public class MyRecycle extends org.zkoss.zkmax.zk.ui.util.DesktopRecycle {
protected boolean shallCache(Desktop desktop, String path, int cause) { return path.startsWith("/long-op"); } protected boolean shallReuse(Desktop desktop, String path, int secElapsed) { return secElapsed >= 300; }
}
=== Implement Your Own Desktop Recycle ===
[Since 5.0.0]
It is straightforward to implement the