从 LStbox ZK 中的多项选择中获取值
我想询问如何从列表框中的多个选择中获取值,我在 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 不为空,就像我想要的那样,如果我在控制器类中传递操作(例如使用方法),则我打印出来的值为空..任何人都想帮助我出了什么问题和我的班级?
我在控制器中的方法是这样的:
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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,经过谷歌搜索、搜索和尝试(:D),我得到了这个问题的答案,你必须做的就是调用控制器中的转换器,我从 ZK 论坛获得的转换器 此处
,并更改返回对象,(机器人返回 null),我的程序将是这样的:
所以我得到了我想要的选定对象..感谢您的关注..:D
litGen
是我的 lisbox IDOK,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:
so i got my selected object i want..thanks for your attention..:D
litGen
is my lisbox id