Reputation: 705
i want to ask about getting value from multiple select in Listbox, i have code in zul like this:
<n:tr>
<n:td>
<label value="Privilege"/>
</n:td>
<n:td>
<label value=""/>
</n:td>
<n:td>
<listbox id="designations" model="@{addUser$composer.lstPrivilege}" selectedItem="@{selectedUserAcc, converter=com.nsia.doku.escrow.converter.SelectedItemConverter}" multiple="true" checkmark="true" width="200px">
<listitem self="@{each=lstPrivilege}" >
<listcell label="@{lstPrivilege.description}"/>
</listitem>
</listbox>
</n:td>
</n:tr>
<n:tr>
<n:td>
</n:td>
<n:td>
</n:td>
<n:td>
<button label="Submit" onClick='
import com.dokuescrow.dto.Activity;
ArrayList al = new ArrayList();
for (Activity li : selectedUserAcc)
{
al.add(li.activityId);
}
alert(al);
'/>
</n:td>
</n:tr>
my problem is,how do i get the selected value in my controller class, i do test in my button using onClick='..
,the value selectedUserAcc not null and like i want,if i pass the action in my controller class (eg. using method),the value i print out is null..anybody want to help me what is wrong with my class?
my method in controller is like this:
public void onClick$submit(Event event){
try {
ArrayList al = new ArrayList();
for (Activity li : selectedUserAcc)
{
al.add(li.getActivityId());
}
alert(al.toString());
} catch (Exception e) {
e.printStackTrace();
}
}
hope somebody can help me..thanks..:D
Upvotes: 1
Views: 4521
Reputation: 705
OK,after googling,searching,and trying (:D),i got answer for this question,the thing you must do is call the converter in your controller,the converter i got from ZK forum here ,and change the return to object,(bot return null),my prgram would be like this:
SelectedItemConverter select=new SelectedItemConverter();
for (Activity li : (Set<Activity>)select.coerceToBean(selectedUserAcc, getListGent()))
{
al.add(li);
}
List<Activity> act=al;
so i got my selected object i want..thanks for your attention..:D
litGen
is my lisbox id
Upvotes: 2