0

Iterate through a list of lists in ZK framework

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

AlwaysALearner gravatar image AlwaysALearner
3 2

updated 2014-11-13 07:50:16 +0800

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 id="arrowUser" />
        </caption>
        <listbox id="lboxUser" />
        <div id="divMoreUsers" style="cursor: pointer; padding: 4px; background-color: rgb(224, 224, 224);">
            <label id="lblMoreUsers" zclass="user_item_label_other" />
        </div>
    </groupbox>
</zk>

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

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-11-23 18:38:37 +0800

Darksu gravatar image Darksu
1991 1 4

updated 2014-11-23 18:44:48 +0800

Hello AlwaysALearner,

You have to update your zul configuration using as a reference the section Apply forEach to Multiple Elements from the url:

http://books.zkoss.org/wiki/ZKDeveloper%27sReference/UIComposing/ZUML/IterativeEvaluation

Specifically please check on the way the components are binded. For example:

<textbox value="${each.value}"/>

Finally please refer to the following url which includes a similar example on nested list boxes:

http://books.zkoss.org/wiki/ZKDeveloper%27sReference/MVC/View/Template/Listbox_Template

Best Regards,

Darksu

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
2 followers

RSS

Stats

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

Seen: 54 times

Last updated: Nov 23 '14

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