GenericAutowireComposer"

From Documentation
m (Created page with '{{ZKDevelopersGuidePageHeader}} If you want to access UI object, you have to call <tt>getFellow</tt> to get its mapping java object. But why not just bind these components and d…')
 
m (correct highlight (via JWB))
 
Line 1: Line 1:
 
{{ZKDevelopersGuidePageHeader}}
 
{{ZKDevelopersGuidePageHeader}}
  
If you want to access UI object, you have to call <tt>getFellow</tt> to get its mapping java object. But why not just bind these components and data beans automatically? In the following example, you can omit the tedious <tt>getFellow</tt> calls, if your applied class extends <tt>GenericAutowireComposer</tt>.
+
If you want to access UI object, you have to call <code>getFellow</code> to get its mapping java object. But why not just bind these components and data beans automatically? In the following example, you can omit the tedious <code>getFellow</code> calls, if your applied class extends <code>GenericAutowireComposer</code>.
  
 
In the following example, Full Name is updated automatically while you change First Name or Last Name.
 
In the following example, Full Name is updated automatically while you change First Name or Last Name.

Latest revision as of 10:41, 19 January 2022

GenericAutowireComposer


Stop.png This documentation is for an older version of ZK. For the latest one, please click here.


If you want to access UI object, you have to call getFellow to get its mapping java object. But why not just bind these components and data beans automatically? In the following example, you can omit the tedious getFellow calls, if your applied class extends GenericAutowireComposer.

In the following example, Full Name is updated automatically while you change First Name or Last Name.

<window apply="Autowired">
    <grid>
        <rows>
            <row>First Name: <textbox id="firstName" forward="onChange=onFirstName"/></row>
            <row>Last Name: <textbox id="lastName" forward="onChange=onLastName"/></row>
            <row>Full Name: <label id="fullName"/></row>
        </rows>
    </grid>
</window>

And the source code of Autowired.java:

import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.util.GenericAutowireComposer;
import org.zkoss.zul.Label;
import org.zkoss.zul.Textbox;


public class Autowired extends GenericAutowireComposer {
    private Textbox firstName; //auto-wired
    private Textbox lastName; //auto-wired
    private Label fullName; //auto-wired

    //all getFellow() codes are removed

    public void onFirstName(Event event) { 
        fullName.setValue(firstName.getValue()+" "+lastName.getValue());
    }
    
    public void onLastName(Event event) {
        fullName.setValue(firstName.getValue()+" "+lastName.getValue());
    }
}

For detail information, please refer to ZK MVC Made Easy.



Last Update : 2022/01/19

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.