0

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:

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?

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
1

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

vincentjian gravatar image vincentjian
2245 6

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.

link publish delete flag offensive edit

Comments

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

Follow
1 follower

RSS

Stats

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