ZK - Open Source Ajax Java FrameworkZK - Open Source Ajax Java Framework

Accessing Component from another ZUL file

swapndipj
31 Jan 2012 08:32:37 GMT
31 Jan 2012 08:32:37 GMT

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.

}

swapndipj
3 Feb 2012 03:45:05 GMT
3 Feb 2012 03:45:05 GMT

Hello techies,

Has anyone get the solutions for this issue?

Thanks
Swapnil

matthewgo
6 Feb 2012 02:17:05 GMT
6 Feb 2012 02:17:05 GMT

Hi Swapnil,
Please try the following code:

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