1

我想问一下如何从列表框中的多项选择中获取价值,我在 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 并且像我想要的那样进行测试,如果我在我的控制器类中传递操作(例如使用方法),我打印出来的值是 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

4

1 回答 1

2

好的,经过谷歌搜索、搜索和尝试(:D),我得到了这个问题的答案,你必须做的就是调用控制器中的转换器,我从 ZK 论坛获得的转换器 并将返回更改为对象, (机器人返回 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

于 2011-06-17T04:03:21.547 回答