Using a template.. but I want to load the first page dynamically? [closed]

asked 2013-12-31 16:04:29 +0800

rickcr gravatar image rickcr
704 7

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:


<?init class="org.zkoss.zk.ui.util.Composition" arg0="layout/template.zul"?>
<include id="mainInclude" self="@define(content)" src=" "/>

relevant template.zul ...

<vlayout apply="com.ncs.ncsadmin.web.controller.NavController">

     <vlayout id="contentSection" self="@insert(content)"></vlayout>

NavController.. was hoping to do...

private Include mainInclude;

public void doAfterCompose(Component comp) throws Exception {
    //logic to get the page from cookie


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?

delete flag offensive retag edit

The question has been closed for the following reason "the question is answered, right answer was accepted" by rickcr
close date 2014-01-02 15:10:18

1 Answer

Sort by ยป oldest newest most voted

answered 2014-01-02 09:05:20 +0800

vincentjian gravatar image vincentjian
2245 6


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.

link publish delete flag offensive edit


Thanks for the zkfiddle. Really appreciate it. I like how you demonstrated setting the page in desktop scope in the template's composer as well.

rickcr ( 2014-01-02 15:09:33 +0800 )edit

Question tools

1 follower



Asked: 2013-12-31 16:04:29 +0800

Seen: 17 times

Last updated: Jan 02 '14

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