0

我正在使用 zk 5.0.3。我想使用以下注释绑定作为边框布局的“中心”区域的标题:

<a:bind content="entrydisplay.activeEntryCaption" /> <html />

我想做以下事情:

<borderlayout>
 <north title="use the above binding here">
   this is north
 </north>
</borderlayout>

如何实现功能,以便我可以将此绑定包装为标题的值?

谢谢,索尼

4

3 回答 3

1

您使用的是过时版本的 ZK 数据绑定。强烈建议您使用最新的方法。

以下链接是 ZK Essential guide & Developer's Reference 的数据绑定部分:

我们的基本数据绑定由一个 POJO 组成,它遵循 Java bean 约定,使用属性中的注释从基于 XML 的接口进行访问。例如:

人 POJO:

public class Person {
    private String _firstName = "";
    private String _lastName = "";
    private Boolean _married = true;

    public Person(){

    }
    public Person(String firstName, String lastName, Boolean married){
        _firstName = firstName;
        _lastName = lastName;
        _married = married;
    }

    // getter and setters


    public void setFullName(String f) {
        // do nothing
    }

    public String getFullName() {
        return _firstName + " " + _lastName;
    }

    //add more here
}

用户界面文件:

<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?>
<window>
    <zscript><![CDATA[
        //prepare the person object
        import bean.Person;
        Person person = new Person();
        person.setFirstName("Max");
        person.setLastName("Planck");
    ]]>
    </zscript>
    <grid width="400px">
        <rows>
            <row> First Name: <textbox value="@{person.firstName}"/></row>
            <row> Last Name: <textbox value="@{person.lastName}"/></row>
            <row> Full Name: <label value="@{person.fullName}"/></row>
        </rows>
    </grid>
</window>

该理论描述为here

于 2010-11-17T08:16:43.000 回答
1

我认为旧方法是这样完成的

<borderlayout>
 <north>
     <attribute name="label">
         <a:bind value="entrydisplay.activeEntryCaption" />
     </attribute>
 </north>
</borderlayout>

新文档 [http://docs.zkoss.org/wiki/Data_binding][数据绑定]的文档

于 2010-11-17T01:39:36.157 回答
0

对于您的特定问题,请如下注释您的组件:

<borderlayout>
 <north id="mynorth" title="@{entrydisplay.activeEntryCaption}">
   this is north
 </north>
</borderlayout>

数据绑定器将读取此类注释并调用 getter 和 setter 方法为您设置北组件的标题。它将执行以下操作:

mynorth.setTitle(entrydisplay.getActiveEntryCaption());
于 2010-11-17T08:28:16.437 回答