-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I'm using a template.zul that is backed by a NavigationComposer. On my index.zul page I want to load the first page - that is I need to look up the last used page from a cookie - the issue is I was hoping I could do this in my NavigationComposer.. but in doAfterCompose the include page id isn't bound yet, so I'm not sure how I can set the source? Maybe there is some other approach to take?
for some reference:
index.zul
<?init class="org.zkoss.zk.ui.util.Composition" arg0="layout/template.zul"?>
<zk>
<include id="mainInclude" self="@define(content)" src=" "/>
</zk>
relevant template.zul ...
<vlayout apply="com.ncs.ncsadmin.web.controller.NavController">
<vlayout id="contentSection" self="@insert(content)"></vlayout>
NavController.. was hoping to do...
@Wire
private Include mainInclude;
@Override
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
//logic to get the page from cookie
mainInclude.setSrc(page);
}
Problem is maininclude is "null" in doAfterCompose since the include hasn't been rendered yet (even using mode="instant"
So what's the best way to solve this situation? Do I have wrap my include in a ViewModel/Composer and load the default page from there?
Hi,
In your case, <?init?> is executed before rendering page (here is index.zul), therefore mainInclude is null. And also, you cannot wire component that is not belong to the zul page.
I would suggest wrap the include component in a Composer. Here is the simple sample in zkfiddle.
Asked: 2013-12-31 16:04:29 +0800
Seen: 17 times
Last updated: Jan 02 '14