-
FEATURED COMPONENTS
First time here? Check out the FAQ!
ZK Version : 6.5
Parent : employee.zul
-------------------------------
<vbox width="600px" height="600px" apply="org.zkoss.bind.BindComposer" viewModel="@id('listvm') @init('foo.ListVM')">
<div id="header">
<toolbar>
<toolbarbutton id="create" image="/images/create.png" onClick="@command('showCreate')"/>
<toolbarbutton id="edit" image="/images/editor.png" onClick="@command('showEdit')"/>
</toolbar>
</div>
<div id="content" width="500px" height="400px">
</div>
<div id="footer">
<button id="return" label="Back" onClick="@command('backToList')"/>
</div>
</vbox>
Child: list.zul
-----------------------
<vbox width="550px">
<groupbox id="list" mold="3d" closable="false">
<caption label="Search"/>
<hbox>
<vbox>
Employee Number
<textbox id="id" value="@bind(listvm.employeeId)"/>
</vbox>
<vbox>
Employee Name
<textbox id="Name" value="@bind(listvm.employeeName)"/>
</vbox>
</hbox>
<button id="find" label="Find" onClick="@global-command('findEmployee')"/>
</groupbox>
</vbox>
Viewmodel which is bind in the parent zul
---------------------------------------------------------
public class ListVM {
@Wire("#find") private Button search;
@Wire("#content") private Div contentPanel;
@AfterCompose
public void composePage(@ContextParam(ContextType.VIEW) org.zkoss.zk.ui.Component view){
Selectors.wireComponents(view, this, false);
search.setVisible(false);
showEmployeeList();
}
public void showEmployeeList() {
Executions.createComponents("list.zul", contentPanel, null);
}
}
While access the page I am getting UI exception. Unable to access the child component find. My requirement is to set some components visible property dynamically.
How to access child zul page components in parent viewmodel?
Could you please help?
Thanks
Abhi
I think You can use Macro Component for this it will easy for you .Have a look here fo Macro Component
Hi Joshi,
Thanks for the suggestion. I saw your ReorderListbox. I am not familier with Macro Component. However, I achieved my expected result by using "@Bind('lalistvm.flagFind')", instead wire the component in viewmodel. Based on the condition setting the flagFind property.
Thanks
Abhi
Asked: 2012-09-24 08:49:32 +0800
Seen: 148 times
Last updated: Sep 24 '12