tags:

views:

359

answers:

1

The zk code below only shows on item... I need it to show all elements in tmp. any idea? thanks <zscript> List tmp=Arrays.asList(new String[]{"a","b","c"}); ]]> </zscript>

<combobox id="mycb" model="@{tmp}"> <comboitem self="@{each=row}" label="xxx" value="yyy"> </comboitem> </combobox>

+1  A: 

You need to initialize the databinder in your ZUL file. In addition there is no need to wrap your array as a List (you can if you want to). The following code works:

<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?> 
<zk>
  <zscript>
      <![CDATA[
          String[] data = new String[]{"a","b","c"};
      ]]>
  </zscript>
  <combobox id="list" width="200px" model="@{data}"/> 
</zk>
Tim
thanks, what if I have a list/array where each element is an array of two object, the first one represents label, the second one represents value. I tried <comboitem self="@{each=row}" label="@{row[0]}" value="row[1]"> not working.
You don't need to use comboitem as an HTML combo. Just set the label with which attribute do you want to show, set the whole object as value and make proper use of equals() method to find items. <comboitem self="@{each=row}" label="@{row.name}" value="@{row}">
Felipe Cypriano