org.zkoss.zkplus.databind
Class DataBinder

java.lang.Object
  extended by org.zkoss.zkplus.databind.DataBinder
Direct Known Subclasses:
AnnotateDataBinder

public class DataBinder
extends java.lang.Object

The DataBinder used for binding ZK UI component and the backend data bean.

Author:
Henri Chen

Field Summary
protected  java.util.Map _collectionItemMap
           
static java.lang.String NULLIFY
           
static java.lang.String TEMPLATE
           
static java.lang.String TEMPLATEMAP
           
static java.lang.String VARNAME
           
 
Constructor Summary
DataBinder()
           
 
Method Summary
 void addBinding(org.zkoss.zk.ui.Component comp, java.lang.String attr, java.lang.String expr)
          Binding bean to UI component.
 void addBinding(org.zkoss.zk.ui.Component comp, java.lang.String attr, java.lang.String expr, java.util.List loadWhenEvents, java.util.List saveWhenEvents, java.lang.String access, java.lang.String converter)
          Binding bean to UI component.
 void addBinding(org.zkoss.zk.ui.Component comp, java.lang.String attr, java.lang.String expr, java.util.List loadWhenEvents, java.lang.String saveWhenEvent, java.lang.String access, java.lang.String converter)
          Binding bean to UI component.
 void addBinding(org.zkoss.zk.ui.Component comp, java.lang.String attr, java.lang.String expr, java.lang.String[] loadWhenEvents, java.lang.String[] saveWhenEvents, java.lang.String access, java.lang.String converter)
          Binding bean to UI component.
 void addBinding(org.zkoss.zk.ui.Component comp, java.lang.String attr, java.lang.String expr, java.lang.String[] loadWhenEvents, java.lang.String saveWhenEvent, java.lang.String access, java.lang.String converter)
          Binding bean to UI component.
 void addCollectionItem(java.lang.String comp, CollectionItem decor)
          Adds a CollectionItem for this comp.
 void bindBean(java.lang.String beanid, java.lang.Object bean)
          Bind a real bean object to the specified beanid.
 boolean existBinding(org.zkoss.zk.ui.Component comp, java.lang.String attr)
          Whether this component and attribute associated with a binding.
 boolean existsBindings(org.zkoss.zk.ui.Component comp)
          Whether this component associated with any bindings.
 Binding getBinding(org.zkoss.zk.ui.Component comp, java.lang.String attr)
          Given component and attr, return the associated Binding.
protected  CollectionItem getBindingCollectionItem(org.zkoss.zk.ui.Component comp)
          Returns a CollectionItem by the comp accordingly.
 java.util.Collection getBindings(org.zkoss.zk.ui.Component comp)
          Given component, return the associated list of Bindings.
protected  void init()
           
 boolean isDefaultConfig()
          Whether use the default binding configuration.
 void loadAll()
          Load all value from data beans to UI components.
 void loadAttribute(org.zkoss.zk.ui.Component comp, java.lang.String attr)
          Load value from the data bean property to a specified attribute of the UI component.
 void loadComponent(org.zkoss.zk.ui.Component comp)
          Load values from the data bean properties to all attributes of a specified UI component.
protected  java.lang.Object[] loadPropertyAnnotation(org.zkoss.zk.ui.Component comp, java.lang.String propName, java.lang.String bindName)
           
 void removeBinding(org.zkoss.zk.ui.Component comp, java.lang.String attr)
          Remove the binding associated with the attribute of the component.
 void saveAll()
          Save all values from UI components to beans.
 void saveAttribute(org.zkoss.zk.ui.Component comp, java.lang.String attr)
          Save value from a specified attribute of the UI component to a data bean property.
 void saveComponent(org.zkoss.zk.ui.Component comp)
          Save values from all attributes of a specified UI component to data bean properties.
 void setDefaultConfig(boolean b)
          Whether use the default binding configuration.
 void setupTemplateComponent(org.zkoss.zk.ui.Component comp, java.lang.Object owner)
          Sets up the specified comp and its decendents to be as template (or not)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULLIFY

public static final java.lang.String NULLIFY
See Also:
Constant Field Values

VARNAME

public static final java.lang.String VARNAME
See Also:
Constant Field Values

TEMPLATEMAP

public static final java.lang.String TEMPLATEMAP
See Also:
Constant Field Values

TEMPLATE

public static final java.lang.String TEMPLATE
See Also:
Constant Field Values

_collectionItemMap

protected java.util.Map _collectionItemMap
Constructor Detail

DataBinder

public DataBinder()
Method Detail

addBinding

public void addBinding(org.zkoss.zk.ui.Component comp,
                       java.lang.String attr,
                       java.lang.String expr)
Binding bean to UI component. This is the same as addBinding(Component comp, String attr, String expr, (List)null, (String)null, (String)null, (String)null).

Parameters:
comp - The component to be associated.
attr - The attribute of the component to be associated.
expr - The expression to associate the data bean.

addBinding

public void addBinding(org.zkoss.zk.ui.Component comp,
                       java.lang.String attr,
                       java.lang.String expr,
                       java.lang.String[] loadWhenEvents,
                       java.lang.String saveWhenEvent,
                       java.lang.String access,
                       java.lang.String converter)
Binding bean to UI component.

Parameters:
comp - The component to be associated.
attr - The attribute of the component to be associated.
expr - The expression to associate the data bean.
loadWhenEvents - The event list when to load data.
saveWhenEvent - The event when to save data.
access - In the view of UI component: "load" load only, "both" load/save, "save" save only when doing data binding. null means using the default access natural of the component. e.g. Label.value is "load", but Textbox.value is "both".
converter - The converter class used to convert classes between component and the associated bean. null means using the default class conversion method.

addBinding

public void addBinding(org.zkoss.zk.ui.Component comp,
                       java.lang.String attr,
                       java.lang.String expr,
                       java.lang.String[] loadWhenEvents,
                       java.lang.String[] saveWhenEvents,
                       java.lang.String access,
                       java.lang.String converter)
Binding bean to UI component.

Parameters:
comp - The component to be associated.
attr - The attribute of the component to be associated.
expr - The expression to associate the data bean.
loadWhenEvents - The event list when to load data.
saveWhenEvents - The event when to save data.
access - In the view of UI component: "load" load only, "both" load/save, "save" save only when doing data binding. null means using the default access natural of the component. e.g. Label.value is "load", but Textbox.value is "both".
converter - The converter class used to convert classes between component and the associated bean. null means using the default class conversion method.
Since:
3.0.0

addBinding

public void addBinding(org.zkoss.zk.ui.Component comp,
                       java.lang.String attr,
                       java.lang.String expr,
                       java.util.List loadWhenEvents,
                       java.lang.String saveWhenEvent,
                       java.lang.String access,
                       java.lang.String converter)
Binding bean to UI component.

Parameters:
comp - The component to be associated.
attr - The attribute of the component to be associated.
expr - The expression to associate the data bean.
loadWhenEvents - The event list when to load data.
saveWhenEvent - The event when to save data.
access - In the view of UI component: "load" load only, "both" load/save, "save" save only when doing data binding. null means using the default access natural of the component. e.g. Label.value is "load", but Textbox.value is "both".
converter - The converter class used to convert classes between component and the associated bean. null means using the default class conversion method.

addBinding

public void addBinding(org.zkoss.zk.ui.Component comp,
                       java.lang.String attr,
                       java.lang.String expr,
                       java.util.List loadWhenEvents,
                       java.util.List saveWhenEvents,
                       java.lang.String access,
                       java.lang.String converter)
Binding bean to UI component.

Parameters:
comp - The component to be associated.
attr - The attribute of the component to be associated.
expr - The expression to associate the data bean.
loadWhenEvents - The event list when to load data.
saveWhenEvents - The event list when to save data.
access - In the view of UI component: "load" load only, "both" load/save, "save" save only when doing data binding. null means using the default access natural of the component. e.g. Label.value is "load", but Textbox.value is "both".
converter - The converter class used to convert classes between component and the associated bean. null means using the default class conversion method.
Since:
3.0.0

removeBinding

public void removeBinding(org.zkoss.zk.ui.Component comp,
                          java.lang.String attr)
Remove the binding associated with the attribute of the component.

Parameters:
comp - The component to be removed the data binding association.
attr - The attribute of the component to be removed the data binding association.

getBinding

public Binding getBinding(org.zkoss.zk.ui.Component comp,
                          java.lang.String attr)
Given component and attr, return the associated Binding.

Parameters:
comp - the concerned component
attr - the concerned attribute

getBindings

public java.util.Collection getBindings(org.zkoss.zk.ui.Component comp)
Given component, return the associated list of Bindings.

Parameters:
comp - the concerned component

existsBindings

public boolean existsBindings(org.zkoss.zk.ui.Component comp)
Whether this component associated with any bindings.


existBinding

public boolean existBinding(org.zkoss.zk.ui.Component comp,
                            java.lang.String attr)
Whether this component and attribute associated with a binding.


isDefaultConfig

public boolean isDefaultConfig()
Whether use the default binding configuration.


setDefaultConfig

public void setDefaultConfig(boolean b)
Whether use the default binding configuration.


bindBean

public void bindBean(java.lang.String beanid,
                     java.lang.Object bean)
Bind a real bean object to the specified beanid. You might not need to call this method because this DataBinder would look up the variable via the Component.getVariable(java.lang.String, boolean) method if it cannot find the specified bean via the given beanid.

Parameters:
beanid - The bean id used in data binding.
bean - The real bean object to be associated with the bean id.

loadAttribute

public void loadAttribute(org.zkoss.zk.ui.Component comp,
                          java.lang.String attr)
Load value from the data bean property to a specified attribute of the UI component.

Parameters:
comp - the UI component to be loaded value.
attr - the UI component attribute to be loaded value.

saveAttribute

public void saveAttribute(org.zkoss.zk.ui.Component comp,
                          java.lang.String attr)
Save value from a specified attribute of the UI component to a data bean property.

Parameters:
comp - the UI component used to save value into backend data bean.
attr - the UI component attribute used to save value into backend data bean.

loadComponent

public void loadComponent(org.zkoss.zk.ui.Component comp)
Load values from the data bean properties to all attributes of a specified UI component.

Parameters:
comp - the UI component to be loaded value.

saveComponent

public void saveComponent(org.zkoss.zk.ui.Component comp)
Save values from all attributes of a specified UI component to data bean properties.

Parameters:
comp - the UI component used to save value into backend data bean.

loadAll

public void loadAll()
Load all value from data beans to UI components.


saveAll

public void saveAll()
Save all values from UI components to beans.


loadPropertyAnnotation

protected java.lang.Object[] loadPropertyAnnotation(org.zkoss.zk.ui.Component comp,
                                                    java.lang.String propName,
                                                    java.lang.String bindName)

init

protected void init()

addCollectionItem

public void addCollectionItem(java.lang.String comp,
                              CollectionItem decor)
Adds a CollectionItem for this comp.

Since:
3.0.0
See Also:
CollectionItem

getBindingCollectionItem

protected CollectionItem getBindingCollectionItem(org.zkoss.zk.ui.Component comp)
Returns a CollectionItem by the comp accordingly.

Since:
3.0.0
See Also:
CollectionItem

setupTemplateComponent

public void setupTemplateComponent(org.zkoss.zk.ui.Component comp,
                                   java.lang.Object owner)
Sets up the specified comp and its decendents to be as template (or not)



Copyright © 2005-2007 Potix Corporation. All Rights Reserved.