Revision history [back]

click to hide/show revision 1
initial version

asked 2014-11-13 07:22:07 +0800

AlwaysALearner gravatar image AlwaysALearner

Iterate through a list of lists in ZK framework

I had already posted my question before. But didn't get any response. So, to be clearer, this is what I'm trying to achieve in zul file (I've written in java just to understand what I actually want to achieve in the UI)

I have the vLayout already populated.

List<Groupbox> groupBoxList = vLayout.getChildren();
        for (Groupbox groupBox : groupBoxList) {
            // Display the Category name
            System.out.println("=================================\n" + groupBox.getCaption().getLabel()
                    + "\n=================================");
            Listbox listBox = (Listbox) groupBox.getChildren().get(1);
            ListModelList itemsList = (ListModelList) listBox.getModel();
            List<CustomUserObject> users = itemsList.getInnerList();
            for (CustomUserObject user : users) {
                // Display the users under this category
                System.out.println(studyUser.getFullName());
                // if the iteration count exceeds 5, then break from this for loop and insert a label which, when on click, loads 5 more, retaining the already existing 5.
            }
            // label to be inserted here, which, onClick, loads 5 more users
        }

Here is my attempt to achieve the same in zul file-

<div class="studyuserlinks_content_container" id="studyuserlinks-content-container">
                <div style="position: relative; width: 100%;">
                    <attribute name="onLoad">
                        <![CDATA[
                            List list = (List) vlyUserRoles.getChildren();
                            for (int i=0;list.size();i++) {
                                <groupbox id="gboxCategory">
                                    <listbox id="lboxUser"/>
                                        <div id="divMoreUsers" 
                                            style="cursor: pointer; padding: 4px; background-color: rgb(224, 224, 224);" visible="false">
                                            <label id="lblMoreUsers" zclass="studyuser_item_label_other" />
                                        </div>
                                </groupbox>
                            }
                        ]]>
                    </attribute>
                </div>

Any idea where I could be going wrong? Any suggestion is much appreciated.

click to hide/show revision 2
updated the UI code

Iterate through a list of lists in ZK framework

I had already posted my question before. But didn't get any response. So, to be clearer, this is what I'm trying to achieve in zul file (I've written in java just to understand what I actually want to achieve in the UI)

I have the vLayout already populated.

List<Groupbox> groupBoxList = vLayout.getChildren();
        for (Groupbox groupBox : groupBoxList) {
            // Display the Category name
            System.out.println("=================================\n" + groupBox.getCaption().getLabel()
                    + "\n=================================");
            Listbox listBox = (Listbox) groupBox.getChildren().get(1);
            ListModelList itemsList = (ListModelList) listBox.getModel();
            List<CustomUserObject> users = itemsList.getInnerList();
            for (CustomUserObject user : users) {
                // Display the users under this category
                System.out.println(studyUser.getFullName());
                // if the iteration count exceeds 5, then break from this for loop and insert a label which, when on click, loads 5 more, retaining the already existing 5.
            }
            // label to be inserted here, which, onClick, loads 5 more users
        }

Here is my attempt to achieve the same in zul file-

<zk forEach="${vLayout}">
    <groupbox id="groupBox" mold="3d" style="top:470px;">
        <caption label="${c:l('caption')}" 
            sclass="toggle_open">
            <div class="studyuserlinks_content_container" id="studyuserlinks-content-container">
                <div style="position: relative; width: 100%;">
                    <attribute name="onLoad">
                        <![CDATA[
                            List list = (List) vlyUserRoles.getChildren();
                            for (int i=0;list.size();i++) {
                                <groupbox id="gboxCategory">
                            id="arrowUser" />
        </caption>
        <listbox id="lboxUser"/>
                                id="lboxUser" />
        <div id="divMoreUsers"  style="cursor: pointer; padding: 4px; background-color: rgb(224, 224, 224);" visible="false">
                                224);">
            <label id="lblMoreUsers" zclass="studyuser_item_label_other" zclass="user_item_label_other" />
         </div>
     </groupbox>
                            }
                        ]]>
                    </attribute>
                </div>
</zk>

But I'm unable to display data in the UI. Any idea where I could be going wrong? Any suggestion is much appreciated.

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More