问题描述
|
我想问有关从列表框中的多个选择中获取价值的问题,我在zul中有这样的代码:
<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>
我的问题是,如何在控制器类中获取选定的值,我使用onClick=\'..
在按钮中进行测试,如果我在控制器类中通过操作(例如,使用方法),则selectedUserAcc值不为空,并且像我想要的那样,我打印出的值是null。任何人都想帮助我我班上怎么了?
我在控制器中的方法是这样的:
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();
}
}
希望有人可以帮助我..谢谢..:D
解决方法
好的,在谷歌搜索,搜索并尝试(:D)之后,我得到了这个问题的答案,您要做的就是在控制器中调用转换器,这是我在ZK论坛上获得的转换器
,然后将return更改为object,(bot return null),我的prgram像这样:
SelectedItemConverter select=new SelectedItemConverter();
for (Activity li : (Set<Activity>)select.coerceToBean(selectedUserAcc,getListGent()))
{
al.add(li);
}
List<Activity> act=al;
所以我得到了我想要的选定对象..谢谢您的关注..:D
litGen
是我的lisbox ID