-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I'm trying to load a .zul page from another page using a button and an onclick event. In the event method I'm executing Executions.createComponent and it does create the component. However, the problem is that it's appending it to the bottom of the original page. I want it to replace the original page. What am I missing?
If you want it to replace current page: I did like this
<?page title="NetMes" contentType="text/html;charset=UTF-8"?> <?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c" ?> <?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" arg0="./maintainWin"?> <zk> <include id="includeWin"></include> <window id="maintainWin" apply="fi.uwasa.netmes.zkossController.MaintainanceController" height="120%" style="padding-top:20px" > <button label="Click" id="btWorkInstruction" /> </window> </zk>
Composer:
public void onClick$btWorkInstruction(Event event){ includeWin.setSrc("maintain/documents.zul"); self.detach(); }
If you want to pass parameter you can do:includeWin.setSrc("maintain/documents.zul?parameter=somethig¶meter2=something");
And in the created window:
String s=Executions.getCurrent().getParameter("parameter");
The second parameter on createComponents() is the parent of the newly created component. Don't know how your layout is since you've shown no example of what you're doing, but the parent of the component that you want to replace is what you should send as the second parameter on createComponents(). Or, do as vinhvo said and call setSrc() on an include.
Thanks, I figured it out. I did this little number:
<code>
//get an instance of the borderlayout defined in the zul-file
Borderlayout bl = (Borderlayout) this.page.getFellow("content");
//get an instance of the searched CENTER layout area
Center center = bl.getCenter();
center.setFlex(true);
//clear the center child comps
center.getChildren().clear();
//create the page and put it in the center layout area
Executions.createComponents(zulFilePathName, center, map);
</code>
It replaces the center portion of my layout with the new component.
:-)
Asked: 2010-06-02 11:26:25 +0800
Seen: 2,012 times
Last updated: Jun 02 '10