Activates Data Binding Manager"
From Documentation
(moved ZK Developer's Guide/ZK in Depth/Data Binding/Activates Data Binding Manager to ZK Developer's Reference/Data Binding/Activates Data Binding Manager) |
m |
||
Line 1: | Line 1: | ||
− | + | {{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. | ||
+ | |||
+ | Person.java | ||
+ | |||
+ | <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> | ||
+ | |||
+ | Then, declare a data source in the page as follows, | ||
+ | |||
+ | <source lang="xml" > | ||
+ | <zscript><![CDATA[ | ||
+ | //prepare the example person object | ||
+ | Person person = new Person(); | ||
+ | person.setFirstName("Tom"); | ||
+ | person.setLastName("Hanks"); | ||
+ | ]]> | ||
+ | </zscript> | ||
+ | </source> | ||
+ | |||
+ | =Version History= | ||
+ | {{LastUpdated}} | ||
+ | {| border='1px' | width="100%" | ||
+ | ! Version !! Date !! Content | ||
+ | |- | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | |} | ||
+ | |||
+ | {{ZKDevelopersGuidePageFooter}} |
Revision as of 04:34, 18 January 2011
This documentation is for an older version of ZK. For the latest one, please click here.
First of all, we have to define a data source as a data bean. In this example, we use Person class as an example that holds the information of a person, say, first name, and last name.
Person.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;
}
}
Then, declare a data source in the page as follows,
<zscript><![CDATA[
//prepare the example person object
Person person = new Person();
person.setFirstName("Tom");
person.setLastName("Hanks");
]]>
</zscript>
Version History
Version | Date | Content |
---|---|---|