2016-08-15 62 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}