I have a page with two different View Models:
<?page title="My page" contentType="text/html;charset=UTF-8"?>
<div apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('com.mycompany.FirstViewModel')">
<!-- A lot of unimportant stuff -->
<tabbox>
<tabs>
<tab label="Tab1" ></tab>
<!-- Other unimportant tabs -->
</tabs>
<tabpanels>
<tabpanel>
<include src="inc/other.zul" p="@ref(vm.selected)" pid="@ref(vm.selected.id)" ></include>
</tabpanel>
</tabpanels>
</tabbox>
</div>
And the include is:
<window>
<label id="sid" value="@load(pid)" />
<div apply="org.zkoss.bind.BindComposer"
viewModel="@id('vms') @init('com.mycompany.SecondViewModel')">
<listbox model="@id('vars') @load(p.someList)"
selectedItem="@bind(vms.selected)"
emptyMessage="No data in list">
<!-- Template and stuff -->
</listbox>
<label id="sid1" value="@load(pid)" />
</div>
</window>
The problem is that once I define the second viewModel, all the external references are inaccessible: I have a value for the first label, but I have no values for the listbox or the second label. Is there a way to do that? I tried with no success to do this:
<div apply="org.zkoss.bind.BindComposer"
viewModel="@id('vms') @init('com.mycompany.SecondViewModel')" list="@ref(p.someList)">
<listbox model="@id('vars') @load(list)"
selectedItem="@bind(vms.selected)"
emptyMessage="No data in list">
I could merge the second View Model in the first one, but that wouldn’t be very convenient! I am also open to other solutions which allow me to have a modular approach.
My version of ZK is 6.0.1
It is (was) actually a bug in ZK, which has been fixed for a future version.