星期三, 4月 06, 2011

[ZK] How to use undo redo button using zk

If you want to use 'undo' and 'redo' button on web browser in your zk website,you can refer to the following link:
ZK Developer's Reference/UI Patterns/Browser History Management



From application's viewpoint, it takes two steps to manage the browser's history:

  1. Add a bookmark to the browser's history for each of the visited states of your desktop.
  2. Listen to the onBookmarkChange event for bookmark change, and switch the state accordingly.

↑ Each bookmark is an arbitrary string added to the browser's history.

Tips:ZK will notify the application by broadcasting the onBookmarkChange event (an instance of the BookmarkEvent class) to all root components in the desktop.



public class BookmarkTesting extends GenericForwardComposer {

 public void doAfterCompose(Component comp) throws Exception {
  
  super.doAfterCompose(comp);
 }
 
 public void onClick$btn1(Event event){
  desktop.setBookmark("btn1");
 }
 
 public void onClick$btn2(Event event){
  desktop.setBookmark("btn2");
 }
 
 public void onBookmarkChange(BookmarkEvent  event) throws Exception {
  System.out.println("-- onBookmarkChange--");
  
  System.out.println(event.getBookmark());
  
  System.out.println("--/ onBookmarkChange--");
 }
  
}

Url looks like:
http://localhpst/test/bookmark.zul#btn1

沒有留言:

張貼留言

留個話吧:)

其他你感興趣的文章

Related Posts with Thumbnails