0

How to add event to listcell children component?

asked 2013-09-13 05:27:32 +0800

1332841633 gravatar image 1332841633
1

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
    }
delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-09-14 06:45:43 +0800

roliroli gravatar image roliroli
164 4

updated 2013-09-14 10:10:47 +0800

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

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

Follow
2 followers

RSS

Stats

Asked: 2013-09-13 05:27:32 +0800

Seen: 25 times

Last updated: Sep 14 '13

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