populate list when clicking on other grid row cell button

asked 2014-12-16 06:17:12 +0800

syeligeti gravatar image syeligeti

updated 2014-12-16 06:26:36 +0800


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)">
        <auxheader colspan="6" class="topic">Country List</auxheader>
        <listheader label="Country Name" align="center" />
        <listheader label="Country Code" align="center" />
    <template name="model" var="country">
                    <button label="@load(country.countryName)" onClick="@command('countryDetails', countryId=country.countryId)"/>
            <listcell label="@load(country.code)" />

viewmodel business logic
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"/>
    <template name="model" var="state">
            <label value="${state.stateName}"/>
            <label value="${state.code}"/>

Please suggest me on this.

delete flag offensive retag edit


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 )edit

In 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

1 Answer

Sort by ยป oldest newest most voted

answered 2014-12-16 08:33:31 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
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, "*");


    // Notify one dependent property.
    BindUtils.postNotifyChange(null, null, CountryViewModel.this, "states");

    return states;
link publish delete flag offensive edit
Your answer
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

1 follower



Asked: 2014-12-16 06:17:12 +0800

Seen: 26 times

Last updated: Dec 16 '14

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