0

onBookmarkChange prevent loading the first page

asked 2009-10-22 06:30:00 +0800

xmedeko gravatar image xmedeko
1031 1 16
http://xmedeko.blogspot.c...

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

delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2009-11-06 05:15:04 +0800

jumperchen gravatar image jumperchen
3909 2 8
http://jumperchen.blogspo... ZK Team

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.

link publish delete flag offensive edit

answered 2009-11-09 09:11:32 +0800

mixgho gravatar image mixgho
193 3

updated 2009-11-09 09:11:55 +0800

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!

link publish delete flag offensive edit

answered 2009-11-10 02:28:37 +0800

xmedeko gravatar image xmedeko
1031 1 16
http://xmedeko.blogspot.c...

updated 2009-11-10 02:34:42 +0800

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

link publish delete flag offensive edit

answered 2009-11-16 09:41:29 +0800

mixgho gravatar image mixgho
193 3

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);
}

link publish delete flag offensive edit

answered 2009-11-17 22:35:05 +0800

jumperchen gravatar image jumperchen
3909 2 8
http://jumperchen.blogspo... ZK Team

Hi,

This feature is closed - https://sourceforge.net/tracker/?func=detail&atid=785194&aid=2896996&group_id=152762
Please give it a try.

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

RSS

Stats

Asked: 2009-10-22 06:30:00 +0800

Seen: 1,138 times

Last updated: Nov 17 '09

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