문제

I am using zk 5.0.3. I want to use the following annotation binding as the title of a "center" region of a borderlayout:

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

I want to do the following:

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

How do I achieve the functionality such that I can wrap this binding as the value of the title?

Thanks, Sony

도움이 되었습니까?

해결책

For your specific question, annotate your component like following:

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

Data binder will read such annotation and call the getter and setter methods to set the title of the north component for you. It will do something like:

mynorth.setTitle(entrydisplay.getActiveEntryCaption());

다른 팁

You are using an outdated version of ZK data binding. It is highly recommended that you make use of the latest methodology.

The following link is the databinding section of the ZK Essential guide & Developer's Reference:

Our basic databinding consists of a POJO which follows the Java bean conventions being access from an XML based interface using annotations in attributes. For example:

Person 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
}

The UI file:

<?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>

The theory is described here.

i think the old way is done it like this

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

The new doc The doc of [http://docs.zkoss.org/wiki/Data_binding][Data Binding]

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top