-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
I have a "one zk desktop" application, something similar to the demo http://www.zkoss.org/zkdemo/userguide/. I have also bookmarks, but I have observed, that when the user reloads the content, first, the home page is displayed and then the page selected by the bookmark is displayed.
To view this issue, just go to the http://www.zkoss.org/zkdemo/userguide/#g6 and do reload the page. First, you see the page http://www.zkoss.org/zkdemo/userguide/#f1 for a moment, and then the proper pagehttp://www.zkoss.org/zkdemo/userguide/#g6 is loaded. Is it possible to avoid loading http://www.zkoss.org/zkdemo/userguide/#f1?
It would be easy, if the onBookamrkChange event would be triggered even in case of empty bookmark. Or if there would be some event which is triggered every time after the page is created and after onBookmarkChange (it this one is triggered). Otherwise I see a solution only by some timer.
Thanks
That seems to be a browser's bookmark behavior, however, you can post it to feature if we can find a way to solve it.
This is not a browser feature. This is how ZK boomarking works.
If you do not want your home page to load first, you have to insert some processBookmark.zul page before homePage.zul, but this approach is usually not feasible.
This happens because navigating method is online (is invoked) after home page initialization is done (considering that you have onBookmarkChange event listener in the Composer of the home page).
This might be resolved by inserting onBookmarkChange listener into beforeComposeChildren() method, but this doesn't work for me. It would be a great feature!
Hi, I have solved this issue by a timer:
<timer id="mainIndexTimer" delay="0" repeats="false" />
and the controller code:
private boolean pageLoaded = false; public void onTimer$mainIndexTimer() throws Exception { if (!this.pageLoaded) { this.onBookmarkChange(null); } } public void onBookmarkChange(BookmarkEvent event) throws Exception { this.pageLoaded = true; // get bookmark String bookmark = null; if (event != null) { bookmark = event.getBookmark(); } if (bookmark == null || bookmark.isEmpty()) { // no bookmark, set default } // process bookmark }
Tested in FF3.5 and IE8
I would recommend solving it this way in Composer class:
public void doAfterCompose(Component aComp) { Events.echoEvent(ON_REDIRECT_TO_BOOKMARK, self, null); } private String ON_REDIRECT_TO_BOOKMARK = "onRedirectToBookmark"; public void onRedirectToBookmark(Event aEvent) { page.addEventListener("onBookmarkChange", new EventListener() { public void onEvent(Event aEvent) throws UiException { bookmarkChange(((BookmarkEvent) aEvent).getBookmark()); } }); if (StringUtils.isBlank(desktop.getBookmark())) { includeId.setSrc(HOME_PAGE); } else { bookmarkChange(desktop.getBookmark()); } } public void bookmarkChange(String aId) { includeId.setSrc(aId); }
Hi,
This feature is closed - https://sourceforge.net/tracker/?func=detail&atid=785194&aid=2896996&group_id=152762
Please give it a try.
Asked: 2009-10-22 06:30:00 +0800
Seen: 1,138 times
Last updated: Nov 17 '09