0

component path/page-id in nested includes

asked 2013-10-15 20:28:48 +0800

robertkaren gravatar image robertkaren
77 7

updated 2013-10-16 17:37:38 +0800

I have several nested <include> , each with its own page-id, but am having trouble finding the Path() for this window. Can someone tell me what I am doing wrong? This java line is in the controller of a Tree in a tab ('Home') and I am looking for path of the window under another tab ('Selections'|'Code Book'). I used 'defer' mode to create a page w/ id on the component's page but I can't find it w/ this java line. The window component (codebookCategoriesWinOuter) is found in the bottom zul page pasted below).

Window codebookCategWin = (Window) new Path("//codebookCategoriesTreePage/codebookCategoriesWinOuter").getComponent();

Here are the zul files. Thanks for any help!

<?page id="mainPage"?>
<zk>
<window id="mainWindow" title="EzTAB" height="100%" width="100%" >
<borderlayout>
    <center border="0">
                <tabbox id="mainTabBox" vflex="1">
                    <tabs id="mainTabs">
                       <tab id="homeTab" label="Home" />
                      <tab id="codebookTab" label="Selections" />
                      <tab id="runReportTab" label="Run Report" />
                      <tab id="logoutTab" label="Logout" />
                    </tabs>
                     <tabpanels>
                       <tabpanel style="background:#111bab">
                            <include id="homeTabPanel" src="/homePanel2.zul"/>
                       </tabpanel>
                       <tabpanel id="codebookTabPanel">
                            <include src="/selectionsPanel.zul"/>
                       </tabpanel>
                      <tabpanel>run report</tabpanel>
                      <tabpanel>
                           <include id="logoutTabPanel" src="/logoutPanel.zul"/>
                      </tabpanel>
                    </tabpanels>
                </tabbox>
    </center>
</borderlayout>
<zscript>
    codebookTab.setVisible(false);
    runReportTab.setVisible(false);
</zscript>
</window>
</zk>

    <!-- <?page id="selectionsPage"?>
-->
    <zk>
    <borderlayout>
        <north size="100%">
            <tabbox id="codebookPanelLeftTabBox" vflex="1">
                <tabs id="codebookPanelLeftTabBoxTabs">
                   <tab id="codebook2Tab" label="Code Book" />
                   <tab id="searchTab" label="Search" />
                </tabs>
                <tabpanels>
                      <tabpanel id="codebookTabpanel">
                        <include src="/codebookCategoriesPanel.zul"/>
                      </tabpanel>
                      <tabpanel id="searchTabpanel">
                        This is search
                      </tabpanel>
                </tabpanels>
            </tabbox>
        </north>
    </borderlayout>
    </zk>

<!--<?page id="codebookCategoriesPanelPage"?>
-->
    <zk>
    <borderlayout>
        <center border="0">
                    <tabbox id="codebookTabBox" vflex="1">
                        <tabs id="codebookTabs">
                          <tab id="codebookCategoriesTab" label="Categories" />
                        <!--  add the result pages here -->
                        </tabs>
                         <tabpanels>
                           <tabpanel id="codebookCategoriesTreeTabPanel">
                                <include mode="defer" src="/codebookCategoriesTreePanel.zul"/>
                           </tabpanel>
                        </tabpanels>
                    </tabbox>
        </center>
    </borderlayout>
    <!-- </window> -->
    </zk>

<?page id="codebookCategoriesTreePage"?>
<zk>
    <window id="codebookCategoriesWinOuter" style="background:#ababab" height="100%" apply="com.namsi.eztab.services.CodebookCategoriesTreeController">
        <borderlayout>
            <center>
                <window id="codebookCategoriesWin" vflex="true" hflex="true">
                    <tree id="codebookCategoriesTree" style="height:18px;"
                        width="100%" vflex="true">
                        <treecols sizable="true">
                           <!--<treecol label="Item" hflex="min" /> -->
                            <treecol width="100%"/>
                            </treecols>
                    </tree>
                </window>
            </center>
          </borderlayout>
    </window>
</zk>
delete flag offensive retag edit

Comments

but why doesn't it work to get the path like I tried. I created new <?page id=codebookCategoriesTreePage?> and should be able to get component codebookCategoriesWinOuter (see last zul I posted) with Path("//codebookCategoriesTreePage/codebookCategoriesWinOuter") but it doens't work.

robertkaren ( 2013-10-16 20:42:52 +0800 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-10-16 20:13:52 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

updated 2013-10-17 08:32:20 +0800

You can use below code to get all component of the page

@Command
 public void doExport(@ContextParam(ContextType.VIEW) Component view) throws IOException {
     logger.debug("Export Button is clicked");
     Listbox auditLogListBox = (Listbox) view.query("Listbox") ;
                       }

There are plenty of other way if you wire the component ID with ViewModel

EDIT:- Check this How to work with include Mainly this part However, if you are using the defer mode and want to access the component inside of them, you have to assign a unique identifier of the page being included. Here is what you can do.

<include mode="defer" src="/mypage.zul?pageId=first"/>
<include mode="defer" src="/mypage.zul?pageId=second"/>

In additions, in the page being include, i.e., mypage.zul in this example, you have to write

<?page id="${param.pageId}"?>

Then, you could access their component by the use of Path as follows.

 Path.getComponent("//first/textbox/");
Path.getComponent("//second/textbox/");

So you have to use like same In your main Zul wrote this code In main.zul file

<include mode="defer" src="/selectionsPanel.zul?pageId=first"/>

In electionsPanel.zul use below line

<?page id="${param.pageId}"?>

Same thing you have to follow other included zuls And in Java code you can use below code

@Override
    public void doAfterCompose(Component comp) throws Exception {
        super.doAfterCompose(comp);
        Tabbox codebookCategWin = (Tabbox) new Path("//first/codebookPanelLeftTabBox").getComponent();
        Tabbox codebookCategWin1 = (Tabbox) new Path("//second/codebookTabbox").getComponent();
        Window win = (Window) new Path("//third/codebookCategoriesWinOuter").getComponent();
        System.out.println();

    }

Note:-Here Composer class added in codebookCategoriesTreePanel.zul

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

RSS

Stats

Asked: 2013-10-15 20:28:48 +0800

Seen: 72 times

Last updated: Oct 17 '13

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