0

Using browser bookmark to navigate

asked 2014-09-11 16:24:33 +0800

gsanmartin gravatar image gsanmartin
25 5

I have a main controller that is assigned to a template zul, there I have a menu where I update certain parts of the website, like I keep the header and footer and the content area is updated via AJAX.

I followed this tutorial:

http://books.zkoss.org/wiki/ZK_Developer's_Reference/UI_Patterns/Browser_History_Management (http://books.zkoss.org/wiki/ZKDeveloper'sReference/UIPatterns/BrowserHistory_Management)

Now in my "main controller" (which I named TemplateController) I subscribe to bookmark changes like this:

private void addEventListenerBookmark(){
        getCurrentPage().addEventListener("onBookmarkChange", new EventListener() {
            public void onEvent(Event event) throws UiException {
                String bookmark = ((BookmarkEvent) event).getBookmark();
                procesaBookmark(bookmark);
            }
        });
    }

which is called on my TemplateController constructor:

  public TemplateController()
    {

        subscribeColaEventos();
    }

This works fine, so if for instance from the index page I select menuoption1 I append #option1 to my url and then I can go back to the index page with the browser.

The problem is, if I directly load index.zul#option1, the rendering process first renders the index page, and when it's done it goes on rendering my option1 page; it seems the controller only gets subscribed to the bookmark event queue after page rendering.

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-09-28 14:27:45 +0800

Darksu gravatar image Darksu
1991 1 4

Hello gsanmartin,

After searching some older posts there are two solutions for your issue:

  1. By using a timer
  2. By creating an echo event

For more information and examples please refer to the following url:

http://forum.zkoss.org/question/38049/onbookmarkchange-prevent-loading-the-first-page/

Best Regards,

Darksu

link publish delete flag offensive edit

Comments

thanks, I'll have a look at those references and give it a try

gsanmartin ( 2014-10-01 07:48:58 +0800 )edit
Your answer
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
1 follower

RSS

Stats

Asked: 2014-09-11 16:24:33 +0800

Seen: 26 times

Last updated: Sep 28 '14

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