Activates Data Binding Manager"

From Documentation
m
m (correct highlight (via JWB))
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
 +
{{Old Version
 +
|url=http://books.zkoss.org/wiki/ZK_Developer's_Reference/Data_Binding
 +
|}}
 
{{ZKDevelopersGuidePageHeader}}
 
{{ZKDevelopersGuidePageHeader}}
  
First of all, we have to define a data source as a data bean. In this example, we use <tt>Person</tt> class as an example that holds the information of a person, say, first name, and last name.
+
Activates Data Binding Manager by defining the page Initializer at the top of the page.
  
Person.java
+
<source lang="xml" >
 
+
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?>
<source lang="java" >
 
public class Person {
 
private String _firstName = "";
 
private String _lastName = "";
 
 
 
// getter and setters
 
public void setFirstName(String firstName) {
 
_firstName = firstName;
 
}
 
 
 
public String getFirstName() {
 
return _firstName;
 
}
 
 
 
public void setLastName(String lastName) {
 
_lastName = lastName;
 
}
 
 
 
public String getLastName() {
 
return _lastName;
 
}
 
 
 
public void setFullName(String f) {
 
// do nothing.
 
}
 
 
 
public String getFullName() {
 
return _firstName + " " + _lastName;
 
}
 
}
 
 
</source>
 
</source>
  
Then, declare a data source in the page as follows,
+
This initiator class do following things:
  
<source lang="xml" >
+
# Creates an <code>AnnotateDataBinder</code> instance.
<zscript><![CDATA[
+
# Sets the <code>AnnotateDataBinder</code> instance as a variable with the name "''binder''" stored in the component as specified in <code>arg0</code> "component-path".(if arg0 is not specified, use <code>Page</code> instead.)
//prepare the example person object
+
# Calls <code>DataBinder.loadAll()</code> to initiate all UI components from the associated data source.
Person person = new Person();
 
person.setFirstName("Tom");
 
person.setLastName("Hanks");
 
]]>
 
</zscript>
 
</source>
 
  
 
=Version History=
 
=Version History=

Latest revision as of 10:39, 19 January 2022

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

Activates Data Binding Manager


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


Activates Data Binding Manager by defining the page Initializer at the top of the page.

<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?>

This initiator class do following things:

  1. Creates an AnnotateDataBinder instance.
  2. Sets the AnnotateDataBinder instance as a variable with the name "binder" stored in the component as specified in arg0 "component-path".(if arg0 is not specified, use Page instead.)
  3. Calls DataBinder.loadAll() to initiate all UI components from the associated data source.

Version History

Last Update : 2022/01/19


Version Date Content
     



Last Update : 2022/01/19

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