-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Now I encountered a problem! I couldn't selected the component where in listbox's templete tag by selector, and couldn't add EventListener.
the zul page like this:
<hbox align="center" style="padding:20px 20px 20px 20px">
${labels.label.organization }
<combobox id="organization" mold="rounded" readonly="true">
<template name="model">
<comboitem label="${each.name }" value="${each.id }"/>
</template>
</combobox>
${labels.label.vault }
<combobox id="vault" mold="rounded" readonly="true">
<template name="model">
<comboitem label="${each.systemName }" value="${each.id }"/>
</template>
</combobox>
</hbox>
<listbox id="boxPriceListbox" vflex="1" height="350px">
<auxhead>
<auxheader label="${labels.label.boxPrice }" />
</auxhead>
<listhead>
<listheader label="${labels.label.boxType}" sort="none"/>
<listheader label="${labels.label.yearRent}" sort="none">
<checkbox id="yearRentCheckbox" />
</listheader>
<listheader label="${labels.label.monthRent}" sort="none">
<checkbox id="monthRentCheckbox"/>
</listheader>
<listheader label="${labels.label.deposit}" sort="none">
<checkbox id="depositCheckbox"/>
</listheader>
</listhead>
<template name="model">
<listitem>
<listcell label="${each.boxType.typeName }"/>
<listcell>
<doublebox value="${each.yearRent }" inplace="true" disabled="${each.yearRentPriceId == null ? true : false }" name="boxYearRent" format="###.##"/>
<button label="${labels.button.saveUpdate }" visible="false"/>
<intbox value="${each.yearRentPriceId }" name="yearRentPriceId" visible="false"/>
<intbox value="${each.boxType.id }" visible="false"/>
</listcell>
<listcell>
<doublebox value="${each.monthRent }" inplace="true" disabled="${each.monthRentPriceId == null ? true : false }" name="boxMonthRent" format="###.##"/>
<button label="${labels.button.saveUpdate }" visible="false"/>
<intbox value="${each.monthRentPriceId }" name="monthRentPriceId" visible="false"/>
<intbox value="${each.boxType.id }" visible="false"/>
</listcell>
<listcell>
<doublebox value="${each.deposit }" inplace="true" disabled="${each.depositPriceId == null ? true : false }" name="boxDeposit" format="###.##"/>
<button label="${labels.button.saveUpdate }" visible="false"/>
<intbox value="${each.depositPriceId }" name="depositPriceId" visible="false"/>
<intbox value="${each.boxType.id }" visible="false"/>
</listcell>
</listitem>
</template>
</listbox>
when user selected second combobox with id="vault" will refresh the listbox data. And in controller I want to selected doublebox with name attributes, but I couldn't selected.
Controller code:
// set listbox model
@Listen("onSelect=#vault")
public void doRefreshBoxPrice() throws Exception {
Integer deviceId = vault.getSelectedItem().getValue();
List<BoxPrice> list = this.priceService.getDeviceBoxPrice(deviceId);
ListModel<BoxPrice> priceListModel = new ListModelList<BoxPrice>(list);
boxPriceListbox.setModel(priceListModel);
}
// add doublebox listener, but couldn't work
@Listen("onChange=doublebox[name='boxYearRent']")
public void doSomething() {
// do something
}
Hello, I guess this may be the ZK Id space issue, you need to specific component in your controller.
try
@Listen("onChange=#boxPriceListbox listitem listcell doublebox[name='boxYearRent']")
or
@Listen("onChange=#boxPriceListbox doublebox[name='boxYearRent']")
more detail: http://books.zkoss.org/wiki/ZKDeveloper'sReference/UIComposing/IDSpace
Asked: 2013-09-13 05:27:32 +0800
Seen: 25 times
Last updated: Sep 14 '13