0

Accessing Component from another ZUL file

asked 2012-01-31 08:32:37 +0800

swapndipj gravatar image swapndipj
30

Hello Everyone,

I am implementing ZK MVC in my project. I have main.zul file which includes list_view.zul file which consist of Listbox component. I want to access the selected list item from Listbox when i click on detail_View button from main.zul file.

following is the code snippet.


Main.ZUL
<?page title="Home"?>
<zk>
<window width="100%" height="100%" id="Main" apply="org.MetricCatalogue.Controllers.MainController">
<borderlayout height="100%" width="100%">
<north size="9%">
<include src="Top.zul"/>
</north>
<west size="85%">
<vbox>
<toolbar id="tb1" sclass="vista" width="1150px" height="27px" align="start">
<toolbarbutton id="List_View" image="images/List_View.png" tooltiptext="List View" />
<toolbarbutton id="Tree_View" image="images/Tree_View.png" tooltiptext="Tree View" />

</toolbar>
<window id="View">
<include src="List_View.zul"/>
</window>
</vbox>
</west>
<east size="15%">
<vbox>
<vbox style="padding:10px;">
<button id="Detail_Search" image="images/detailes.png" label="Detail View" width="180px" height="35px"/>
</vbox>
<listbox>
<listhead>
<listheader label="Metric Catalogue Wall" />
</listhead>
</listbox>
</vbox>

</east>
</borderlayout>
</window>
</zk>


List_View.ZUL

<?page id="listPage"?>
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit"?>
<zk>
<zscript>
<![CDATA[
import org.MetricCatalogue.Model.MetricMaster;
import org.MetricCatalogue.DAO.MetadataExtractor;
List persons = new ArrayList();
MetadataExtractor me=new MetadataExtractor();
persons=me.listMetadata();
]]>
<listbox model="@{persons}" apply="org.MetricCatalogue.Controllers.MainController" id="Metric_List" width="99%" style="padding:2px" mold="paging" pageSize="7">
<listhead>
<listheader label="Metric ID" width="10%"/>
</listhead>
<listitem self="@{each=MetricMaster}" value="@{MetricMaster}">
<listcell label="@{MetricMaster.MetricID}"/>
</listitem>
</listbox>
</zk>


Controller:
public void onClick$Detail_Search(Event e)
{
How can I access the selected List item from List_View.ZUL Metric_List.

}

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2012-02-03 03:45:05 +0800

swapndipj gravatar image swapndipj
30

Hello techies,

Has anyone get the solutions for this issue?

Thanks
Swapnil

link publish delete flag offensive edit

answered 2012-02-06 02:17:05 +0800

matthewgo gravatar image matthewgo
375

Hi Swapnil,
Please try the following code:

(Listbox)Path.getComponent("/Main/View/inc/Metric_List")).getSelectedItem()

link publish delete flag offensive edit
Your reply
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

RSS

Stats

Asked: 2012-01-31 08:32:37 +0800

Seen: 138 times

Last updated: Feb 06 '12

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