2016-08-15 86 views
1

我的嘗試:如何在ZK UI中顯示ArrayList?

 <tabpanel> 
      <listbox id="usersList" sizedByContent="true" span="true" model="@{users}"> 
       <listhead> 
        <listheader label="User Name"/> 
        <listheader label="gender"/> 
       </listhead> 
       <listitem self="@{each=users}"> 
        <listcell label="@{user.userName}"/>  
        <listcell label="@{user.gender}"/> 
       </listitem> 
      </listbox> 
     </tabpanel> 

而在Java方面:我有ArrayList的用戶,如果點擊提交後,添加到這個列表中的用戶....但我不知道如何在UI端顯示出來。 ...任何人都可以幫助我嗎?非常感謝....即時新聞與ZK

+0

你已經在ZUL中聲明你的視圖模型?別忘了在前面使用viewmodel的id,你可以像使用zscript風格一樣使用它 – chillworld

回答

0

您可以使用標籤<template>。 試試下面的代碼:

 <tabpanel> 
      <listbox id="usersList" sizedByContent="true" span="true" model="${users}"> 
       <listhead> 
        <listheader label="User Name"/> 
        <listheader label="gender"/> 
       </listhead> 
       <template name="model" var="user"> 
        <listitem> 
         <listcell label="${user.userName}"/>  
         <listcell label="${user.gender}"/> 
        </listitem> 
       </template> 
      </listbox> 
     </tabpanel> 

但是如果你的列表更改應用程序運行時,您可以使用@load(users)代替${users}