Revision history [back]

click to hide/show revision 1
initial version

asked 2012-05-28 10:46:31 +0800

kjir gravatar image kjir

Injecting reference in a div with a view model

Hi, I have a page with 2 view models:

<?page title="Manage stands" 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>

The include is like this:

<window>
<label id="sid" value="@load(pid)" ></label>
<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)" ></label>
</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">
Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More