-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
I am new to ZK framework. I have two grids in same zul file. When ever i click on first grid row cell button then i need to populate other grid.
For this i have written viewmodel, when ever i click on button am calling viewmodel notifyChange event and written business logic to get details of list to populate other grid. But the list of object while accessing in zul file am not able to get value.
zul file
first grid contains button in row
------------------
<window apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('com.hm.controller.CountryViewModel')">
<listbox vflex="true" hflex="1" model="@load(vm.countryData.countries)">
<auxhead>
<auxheader colspan="6" class="topic">Country List</auxheader>
</auxhead>
<listhead>
<listheader label="Country Name" align="center" />
<listheader label="Country Code" align="center" />
</listhead>
<template name="model" var="country">
<listitem>
<listcell>
<hbox>
<button label="@load(country.countryName)" onClick="@command('countryDetails', countryId=country.countryId)"/>
</hbox>
</listcell>
<listcell label="@load(country.code)" />
</listitem>
</template>
</listbox>
viewmodel business logic
----------------------------
@Command
@NotifyChange("countryDetails")
public List<State> countryDetails(@BindingParam("countryId") int countryId) {
List<State> states = new CountryDaoImpl().getStates(countryId);
return states;
}
second grid in same zul file
---------------------
<grid model="${states}" emptyMessage="Nothing in Domain" height="400px">
<columns sclass="tableDataHeading">
<column label="state Name" sclass="w10"/>
<column label="code" sclass="w20"/>
</columns>
<template name="model" var="state">
<row>
<label value="${state.stateName}"/>
<label value="${state.code}"/>
</row>
</template>
</grid>
Please suggest me on this.
Thanks,
Sreedhar
@Command
@NotifyChange("countryDetails")
public List<State> countryDetails(@BindingParam("countryId") int countryId) {
List<State> states = new CountryDaoImpl().getStates(countryId);
// Notify all dependent properties.
BindUtils.postNotifyChange(null, null, CountryViewModel.this, "*");
or:
// Notify one dependent property.
BindUtils.postNotifyChange(null, null, CountryViewModel.this, "states");
return states;
}
Asked: 2014-12-16 06:17:12 +0800
Seen: 26 times
Last updated: Dec 16 '14
ZK drang and drop and databinding [closed]
Create a Zk session variable with a menu
Using databinding in menupopup
ZK Clustering, Session Replication Question [closed]
AnnotateDataBinder: when the expr is pointing to a NULL object
Editable interface to add users
Thanks for reply. I have followed as per your suggestion. But still am getting states list value as empty in zul file. Please Can you help me on this issue.
syeligeti ( 2014-12-18 05:22:06 +0800 )editIn the command, you should notify change states instead of countryDetails. And the grid model should be @load(vm.states) instead of EL ${states}.
vincentjian ( 2015-01-20 06:42:24 +0800 )edit