0

Unable to @Wire child zul page components in parent zul viewmodel using MVVM

asked 2012-09-24 08:49:32 +0800

abhi2008 gravatar image abhi2008
61 1 1 4

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

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2012-09-24 09:05:58 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

I think You can use Macro Component for this it will easy for you .Have a look here fo Macro Component

link publish delete flag offensive edit

answered 2012-09-24 13:56:52 +0800

abhi2008 gravatar image abhi2008
61 1 1 4

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

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2012-09-24 08:49:32 +0800

Seen: 148 times

Last updated: Sep 24 '12

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