2011-06-15 35 views
1

我想请教一下在列表框中从多个选择中获得价值,我已经在ZUL代码:充分利用多选择在列表框中ZK值

<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(); 
     } 

    } 

希望有人能帮助me..thanks ..:d

回答

2

OK,谷歌搜索,搜索和尝试后(:d),我得到了这个问题的答案,你必须做的事情是在你的控制器中调用转换器,我从ZK论坛here 得到的转换器,并将返回更改为对象,(bot返回null),我的代码将如下所示:

SelectedItemConverter select=new SelectedItemConverter(); 

     for (Activity li : (Set<Activity>)select.coerceToBean(selectedUserAcc, getListGent())) 
         { 
          al.add(li); 
         } 


         List<Activity> act=al; 

,所以我有我选择的对象我want..thanks的关注..:d

litGen是我lisbox ID