Java Doc for AnnotateDataBinder.java in  » Ajax » zk » org » zkoss » zkplus » databind » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Ajax » zk » org.zkoss.zkplus.databind 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.zkoss.zkplus.databind.DataBinder
      org.zkoss.zkplus.databind.AnnotateDataBinder

AnnotateDataBinder
public class AnnotateDataBinder extends DataBinder (Code)

The DataBinder that reads ZUML annotations to create binding info. The ZUML page must declare the XML namespace, xmlns:a="http://www.zkoss.org/2005/zk/annotation", to use the ZUML annotations. The annotation is declared before each Component or specified directly on the Component attributes. For example, the following annotation associates the attibute "value" of the component "textbox" to the bean's value "person.address.city".

 <a:bind value="person.address.city"/>
 <textbox/>
 

Or since ZK 2.4 you can annotate directly on the attribute "value" of the component "textbox" like this.

 <textbox value="@{person.address.city}"/>
 

The @{...} pattern tells the ZUML parser that this is for annotation.

The AnnotateDataBinder knows "a:bind" annotation only. The complete format is like this if you declared it before the Component.

 <a:bind attrY="bean's value;[tag:expression]..."/>
 <componentX/>
 

You can also specify directly on the Component attribute, the complete format is like this:

 <componentX attrY="@{bean's value,[tag='expression']...}"/>
 

This associates the componentX's attribute attrY to the bean's value. The bean's value is something in the form of beanid.field1.field2... You can either call DataBinder.bindBean to bind the beanid to a real bean object or you can neglect it and this DataBinder would try to find it from the variables map via ( org.zkoss.zk.ui.Component.getVariable method. That is, all those variables defined in zscript are accessible by this DataBinder. Note that you can choose either two formats of annotaion as your will and you can even hybrid them together though it is generaly not a good practice.

The tag:expression or tag='expression' is a generic form to bind more metainfo to the attrY of the componentX. The currently supported tag includes "load-when", "save-when", "access", and "converter"

  • load-when. You can specify the events concerned when to load the attribute of the component from the bean. Multiple definition is allowed and would be called one by one. For example, the following code snip tells DataBinder that the attribute "value" of Label "fullName" will load from "person.fullName" when the Textbox "firstName" or "lastName" fire "onChange" event.

    Declare in front of the Component:

     <a:bind value="person.firstName"/>
     <textbox id="firstname"/>
     <a:bind value="person.lastName"/>
     <textbox id="lastname"/>
     <a:bind value="person.fullName; load-when:firstname.onChange; load-when:lastname.onChange"/>
     <label id="fullname"/>
     

    Or specify directly on the Component's attribute:

     <textbox id="firstname" value="@{person.firstName}"/>
     <textbox id="lastname" value="@{person.lastName}"/>
     <label id="fullname" value="@{person.fullName, load-when='firstname.onChange,lastname.onChange'}"/>
     
  • save-when. You can specify the events concerned when to save the attribute of the component into the bean. Since ZK version 3.0.0, you can specify multiple events in save-when tag (i.e. before ZK 3.0.0, you can specify only one event). The events specified, if fired, will trigger this DataBinder to save the attribute of the component into bean. For example, the following code snip tells DataBinder that the attribute "value" of Textbox "firstName" will save into "person.firstName" when the Textbox itself fire "onChange" event.

    Declare in front of the Component:

     <a:bind value="person.firstName; save-when:self.onChange"/>
     <textbox id="firstName"/>
     

    Or specify directly on the Component's attribute:

     <textbox id="firstName" value="@{person.firstName, save-when='self.onChange'}"/>
     

    However, you don't generally specify the save-when tag. If you don't specify it, the default events are used depends on the natural charactieric of the component's attribute as defined in lang-addon.xml. For example, the save-when of Label.value is default to none while that of Textbox.value is default to self.onChange. That is, the following example is the same as the above one.

    Declare in front of the Component:

     <a:bind value="person.firstName"/>
     <textbox id="firstName"/>
     

    Or specifies directly on the Component's attribute:

     <textbox id="firstName" value="@{person.firstName}"/>
     

    On the other hand, you might not specify the save-when tag nor you want the default events to be used. Then you can specify a "none" keyword or simply leave empty to indicate such cases.

     <a:bind value="person.firstName; save-when:none;"/>
     <textbox id="firstName"/>
     
    or
     <a:bind value="person.firstName; save-when: ;"/>
     <textbox id="firstName"/>
     
    or
     <textbox id="firstName" value="@{person.firstName, save-when='none'}"/>
     
    or
     <textbox id="firstName" value="@{person.firstName, save-when=''}"/>
     
  • Since 3.0.0, DataBinder supports validation phase before saving attribute content into bean property when triggered by the specified event in save-when tag. It will fire onBindingSave event to the data-binding component and then fire onBindingValidate to the triggering component before really saving component attribute contents into bean's property. So application developers get the chance to handle the value validatiion before saving. In the following example when end user click the "savebtn" button, an "onBindingSave" is first fired to "firtName" and "lastName" textboxes and then an "onBindingValidate" is fired to "savebtn" button. Application developers can register proper event handlers to do what they want to do.

     <textbox id="firstName" value="@{person.firstName, save-when="savebtn.onClick"}" onBindingSave="..."/>
     <textbox id="lastName" value="@{person.lastName, save-when="savebtn.onClick"}" onBindingSave="..."/>
     <button id="savebtn" label="save" onBindingValidate="..."/>
     

    Note that the original textbox constraint mechanism is still there. This DataBinder validation phase is an add-on feature that can be applied to all components and attributes that use data binding mechanism.

  • access. You can set the access mode of the attrY of the componentX to be "both"(load/save), "load"(load Only), "save"(save Only), or "none"(neither). Multiple definition is NOT allowed and the later defined would override the previous defined one. The access mode would affects the behavior of the DataBinder's loadXxx and saveXxx methods. The DataBinder.loadAll and DataBinder.loadComponent would load only those attributes with "both" or "load" access mode. The DataBinder.saveAll and DataBinder.saveComponent would save only those attributes with "both" or "save" access mode. If you don't specify it, the default access mode depends on the natural characteristic of the component's attribute as defined in lang-addon.xml. For example, Label.value is default to "load" access mode while Textbox.value is default to "both" access mode. For example, the following code snips tells DataBinder that Textbox "firstName" would allowing doing save into bean only not the other way.

    Declare in front of the Component:

     <a:bind value="person.firstName;access:save;"/>
     <textbox id="firstName"/>
     

    Or specify directly on the Component's attribute:

     <textbox id="firstName" value="@{person.firstName, access='save'}"/>
     
  • converter. You can specify the class name of the converter that implments the TypeConverter interface. It is used to convert the value between component attribute and bean field. Multiple definition is NOT allowed and the later defined would override the previous defined one. Most of the time you don't have to specify this since this DataBinder supports converting most commonly used types. However, if you specify the TypeConverter class name, this DataBinder will new an instance and use it to cast the class.

since:
   2.4.0 Supporting @{...} annotations.
since:
   3.0.0 Supporting multiple events of save-when tag and validation phase.
author:
   Henri Chen
See Also:   AnnotateDataBinderInit
See Also:   DataBinder



Constructor Summary
public  AnnotateDataBinder(Desktop desktop)
     Constructor that read all binding annotations of the components inside the specified desktop.
public  AnnotateDataBinder(Page page)
     Constructor that read all binding annotations of the components inside the specified page.
public  AnnotateDataBinder(Component comp)
     Constructor that read all binding annotations in the components inside the specified component (inclusive).
public  AnnotateDataBinder(Component[] comps)
     Constructor that read all binding annotations of the given components array.
public  AnnotateDataBinder(Desktop desktop, boolean defaultConfig)
     Constructor that read all binding annotations of the components inside the specified desktop.
public  AnnotateDataBinder(Page page, boolean defaultConfig)
     Constructor that read all binding annotations of the components inside the specified page.
public  AnnotateDataBinder(Component[] comps, boolean defaultConfig)
     Constructor that read all binding annotations of the given component array.
public  AnnotateDataBinder(Component comp, boolean defaultConfig)
     Constructor that read all binding annotations in the components inside the specified component (inclusive).



Constructor Detail
AnnotateDataBinder
public AnnotateDataBinder(Desktop desktop)(Code)
Constructor that read all binding annotations of the components inside the specified desktop.
Parameters:
  desktop - the ZUML desktop.



AnnotateDataBinder
public AnnotateDataBinder(Page page)(Code)
Constructor that read all binding annotations of the components inside the specified page.
Parameters:
  page - the ZUML page.



AnnotateDataBinder
public AnnotateDataBinder(Component comp)(Code)
Constructor that read all binding annotations in the components inside the specified component (inclusive).
Parameters:
  comp - the ZUML component.



AnnotateDataBinder
public AnnotateDataBinder(Component[] comps)(Code)
Constructor that read all binding annotations of the given components array.
Parameters:
  comps - the Component array.
since:
   3.0.0



AnnotateDataBinder
public AnnotateDataBinder(Desktop desktop, boolean defaultConfig)(Code)
Constructor that read all binding annotations of the components inside the specified desktop.
Parameters:
  desktop - the ZUML desktop.
Parameters:
  defaultConfig - whether load default binding configuration defined in lang-addon.xml



AnnotateDataBinder
public AnnotateDataBinder(Page page, boolean defaultConfig)(Code)
Constructor that read all binding annotations of the components inside the specified page.
Parameters:
  page - the ZUML page.
Parameters:
  defaultConfig - whether load default binding configuration defined in lang-addon.xml



AnnotateDataBinder
public AnnotateDataBinder(Component[] comps, boolean defaultConfig)(Code)
Constructor that read all binding annotations of the given component array.
Parameters:
  comps - the Component array
Parameters:
  defaultConfig - whether load default binding configuration defined in lang-addon.xml
since:
   3.0.0



AnnotateDataBinder
public AnnotateDataBinder(Component comp, boolean defaultConfig)(Code)
Constructor that read all binding annotations in the components inside the specified component (inclusive).
Parameters:
  comp - the ZUML component.
Parameters:
  defaultConfig - whether load default binding configuration defined in lang-addon.xml




Fields inherited from org.zkoss.zkplus.databind.DataBinder
final public static String NULLIFY(Code)(Java Doc)
final public static String TEMPLATE(Code)(Java Doc)
final public static String TEMPLATEMAP(Code)(Java Doc)
final public static String VARNAME(Code)(Java Doc)
protected Map _collectionItemMap(Code)(Java Doc)

Methods inherited from org.zkoss.zkplus.databind.DataBinder
public void addBinding(Component comp, String attr, String expr)(Code)(Java Doc)
public void addBinding(Component comp, String attr, String expr, String[] loadWhenEvents, String saveWhenEvent, String access, String converter)(Code)(Java Doc)
public void addBinding(Component comp, String attr, String expr, String[] loadWhenEvents, String[] saveWhenEvents, String access, String converter)(Code)(Java Doc)
public void addBinding(Component comp, String attr, String expr, List loadWhenEvents, String saveWhenEvent, String access, String converter)(Code)(Java Doc)
public void addBinding(Component comp, String attr, String expr, List loadWhenEvents, List saveWhenEvents, String access, String converter)(Code)(Java Doc)
public void addCollectionItem(String comp, CollectionItem decor)(Code)(Java Doc)
public void bindBean(String beanid, Object bean)(Code)(Java Doc)
public boolean existBinding(Component comp, String attr)(Code)(Java Doc)
boolean existsBean(String beanid)(Code)(Java Doc)
public boolean existsBindings(Component comp)(Code)(Java Doc)
Object getBean(String beanid)(Code)(Java Doc)
Object getBeanAndRegisterBeanSameNodes(Component comp, String path)(Code)(Java Doc)
Set getBeanSameNodes(Object bean)(Code)(Java Doc)
public Binding getBinding(Component comp, String attr)(Code)(Java Doc)
protected CollectionItem getBindingCollectionItem(Component comp)(Code)(Java Doc)
public Collection getBindings(Component comp)(Code)(Java Doc)
static boolean hasTemplateOwner(Component comp)(Code)(Java Doc)
protected void init()(Code)(Java Doc)
static boolean isClone(Component comp)(Code)(Java Doc)
public boolean isDefaultConfig()(Code)(Java Doc)
static boolean isTemplate(Component comp)(Code)(Java Doc)
public void loadAll()(Code)(Java Doc)
public void loadAttribute(Component comp, String attr)(Code)(Java Doc)
public void loadComponent(Component comp)(Code)(Java Doc)
protected Object[] loadPropertyAnnotation(Component comp, String propName, String bindName)(Code)(Java Doc)
Object lookupBean(Component comp, String beanid)(Code)(Java Doc)
static Component lookupClone(Component srcClone, Component srcTemplate)(Code)(Java Doc)
static List parseExpression(String expr, String separator)(Code)(Java Doc)
Set removeBeanSameNodes(Object bean)(Code)(Java Doc)
public void removeBinding(Component comp, String attr)(Code)(Java Doc)
public void saveAll()(Code)(Java Doc)
public void saveAttribute(Component comp, String attr)(Code)(Java Doc)
public void saveComponent(Component comp)(Code)(Java Doc)
void setBean(String beanid, Object bean)(Code)(Java Doc)
void setBeanAndRegisterBeanSameNodes(Component comp, Object val, Binding binding, String path, boolean autoConvert, Object rawval, List loadOnSaveInfos)(Code)(Java Doc)
void setBeanSameNodes(Object bean, Set set)(Code)(Java Doc)
public void setDefaultConfig(boolean b)(Code)(Java Doc)
public void setupTemplateComponent(Component comp, Object owner)(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.