i want to creat a selectbox to load an array of values into it.
I have written the code but the values are not loading into the selectbox so, it is empty. I think, the connection between controller and the view is incorrect. Can you please help? Thanks in advance.
<zk xmlns="">
<window id="win" apply="hw.SalesController">
<grid sclass="editHeader">
<columns visible="false">
<column width="150px"/>
<column/>
</columns>
<rows>
<row>
<cell>
Sales Type
</cell>
<cell>
<!--SELECTBOX-->
<selectbox id="salesTypeListbox" model="${$composer.salesModel}"
>
<template name="model">
<listitem label="${each}" />
</template>
</selectbox>
</cell>
</row>
</rows>
</grid>
</window>
</zk>
public class SalesController extends SelectorComposer<window> {
private ListModelList<String> salesModel = new ListModelList<String>(SalesHeader.getSalesType());
}
public class SalesHeader {
public static List<String> getSalesType() {
return Arrays.asList(new String[]{"BU-0", "BU-1", "BU-2", "BU-3"});
}
}
There are two problems:
The first error is
Property 'salesModel' not found on type [your composer class]
This is because you are missing a getter-method in your composer:
public ListModelList<String> getSalesModel() {
return salesModel;
}
The second error is regarding the listitem
element in your selectbox's template. It's causing:
Listitem's parent must be Listbox, not Selectbox
You can overcome that by simply using each
or a label
element in your template:
<template name="model">
${each}
</template>
Here you can find a working ZKFiddle example.