0

onBookmarkChange and update component via ajax

asked 2013-05-16 10:52:25 +0800

bluegod gravatar image bluegod
3 2

updated 2013-05-16 11:26:00 +0800

I have an AJAX based navigation via tabs using includeComponent.setSrc(page) in order to change the page displayed inside the component. I can capture the onBookmarkChange when it gets fired in the page using:

(myViewModel.groovy)

@Wire("#navTabbox")
Tabbox navTabbox     
 void onBookmarkChange(@BindingParam("bookmark") String bookmark) {
    navRequestService.navigate(page, navTabbox)
}

The method navigate does the setSrc bit however, navTabbox is null at this stage!

The ZUL page(s) have the following structure:

<zk>

    <window id="wnd" apply="grailsBindComposer" onBookmarkChange="@command('onBookmarkChange', bookmark=wnd.desktop.bookmark)"
            viewModel="@id('vm') @init('myViewModel')">
        <borderlayout sclass="templateLayout" hflex="1" vflex="1" height="1024px;">
        <north sclass="north">
            <include src="bar.zul"/>
        </north>
        <center id="mainContent" autoscroll="false" border="none" self="@insert(content)" flex="true" hflex="1" >
        </center>
    </borderlayout>
</window>
</zk>

(Relevant code inside bar.zul)

   <tabbox id="navTabbox"
                apply="grailsBindComposer"
                viewModel="@id('vm') @init('myViewModel')">
     <tabs id="tabs">
                <tab label="page1"  onClick='desktop.setBookmark("page0")' onSelect="@command('navigate', page='page1.zul')" />
[...]
            <tabpanel>
                <toolbar hflex="true">
                    <toolbarbutton image="blah.png"
                                   label="page1"
                                   onClick="@command('navigate', page='page1.zul')"/>
                  </toolbar>
            </tabpanel>
    </tabbox>

So when I press the toolbar button it navigates to page1 and navTabbox != null. All good. However, when I trigger the onBookmarkChange event for instance pressing the back button, then navTabbox is null.

It looks like since the onBookmarkChange event is set at the window as the first root element of the page it can't reach that component ?

I've also tried getting the component via wnd.query("#navTabbox") but it's still null in the onBookmarkChange method.

Any ideas?

Thanks in advance.

delete flag offensive retag edit
Be the first one to answer this question!
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
2 followers

RSS

Stats

Asked: 2013-05-16 10:52:25 +0800

Seen: 31 times

Last updated: May 16 '13

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