Search code examples
javaarraylistzk

How can i show an ArrayList in ZK ui?


what i tried:

       <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>

And in java side: i have ArrayList users, and if click submit after add to this list a user....but i not know how to display it in UI side....can anyone helps to me? Thanks a lot....im newbie with zk


Solution

  • You can use the tag <template>. Try the following code:

           <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>
    

    But if your list changes while the application is running, you can use @load(users) instead of ${users}