1

I have got tabbox with several items. I need to refresh data when user click on tab. I have click command that perform refreshing in the container, but I can't create refreshing of the page. This is example of item on .zul page:

<row valign="top">
    <label value="Title with diacritics" zclass="field_label"/> 
    <textbox value="@{main$composer.inventory.titleTranslitDcr, is-live=true}"  hflex="1"/>
</row>

This is how this data which I tried to set in the bean:

public void populateTitleStatementFields()
{
    this.titleTranslitDcr = Commons.getString(context, "/xml/TitleTranslitDCR", EMPTY);
}

I'm sure that in this code I've got valid value of the string. But nothing work until full reload with F5.

As for samples - I have got about 50+ fields which I should update in 5 includes. I tested this by opening two pages - at one I save data into db, on other change tab and looking for changes, but nothing happened, even if I got right value from db (which was changed on another browser instance) EDIT 11.04.2013:

Found something close to this. Reloading .zul page from onclick event in tutorial, but I think I should combine it with @Command. Is there a way to do it just to test will it work?

4

1 回答 1

1

您可以使用 ZK MVVM 执行此操作,如下所示:

测试.zul

<zk>
    <div apply="org.zkoss.bind.BindComposer"
        viewModel="@id('vm') @init('test.TestVM')">
        <tabbox onSelect="@command('updateData')">
            <tabs>
                <tab label="tab 1" />
                <tab label="tab 2" />
            </tabs>
            <tabpanels>
                <tabpanel>
                    <label value="@load(vm.dataOne)" />
                </tabpanel>
                <tabpanel>
                    <label value="@load(vm.dataTwo)" />
                </tabpanel>
            </tabpanels>
        </tabbox>
    </div>
</zk>

TestVM.java

package test;

import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.NotifyChange;


public class TestVM {
    public String getDataOne () {
        return System.currentTimeMillis() % 19 + "";
    }
    public String getDataTwo () {
        return System.currentTimeMillis() % 91 + "";
    }
    @Command
    @NotifyChange({"dataOne", "dataTwo"})
    public void updateData () {

    }
}
于 2013-04-12T07:28:02.253 回答