Package org.zkoss.bind
Interface Binder
- All Known Implementing Classes:
AnnotateBinder,BinderImpl,DefaultBinder
public interface Binder
The Binder that do the data binding things.
- Since:
- 6.0.0
- Author:
- henrichen, dennischen
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringAttribute ofZKBINDannotation, the access direction: can be "both", "save", "load"; default to "load" if not foundstatic final intIndicates the doing command is failure with some validation errors.static final intIndicates the doing command is successful.static final StringAttribute ofZKBINDannotation, the system converter for special properties. e.g.static final StringAttribute ofZKBINDannotation, the load trigger event; meaningful only when ACCESS is "both" or "load" or not found(default to "load").static final StringAttribute ofZKBINDannotation, the load replacement ; e.g. value of textbox, it loads to rawValuestatic final StringAttribute ofZKBINDannotation, the type of attribute for loading; e.g. rawValue of textbox is java.lang.Stringstatic final StringAttribute ofZKBINDannotation, the special renderer for bindingstatic final StringAttribute ofZKBINDannotation, the save trigger event; meaningful only when ACCESS is "both" or "save".static final StringAttribute ofZKBINDannotation, the save replacement ; e.g. selectedItem of selectbox, it save the value selectedIndex (via converter) to beanstatic final StringAttribute ofZKBINDannotation, the system validator for special properties.static final StringComponent annotation of ZKBind -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChildrenInitBinding(org.zkoss.zk.ui.Component comp, String initExpr, Map<String, Object> initArgs, String converterExpr, Map<String, Object> converterArgs) init children of a component by an expression, it only execute oncevoidaddChildrenLoadBindings(org.zkoss.zk.ui.Component comp, String loadExpr, String[] beforeCmds, String[] afterCmds, Map<String, Object> bindingArgs, String converterExpr, Map<String, Object> converterArgs) Add new children-load-bindings.voidaddCommandBinding(org.zkoss.zk.ui.Component comp, String evtnm, String commandExpr, Map<String, Object> commandArgs) Add a new command binding.voidaddFormInitBinding(org.zkoss.zk.ui.Component comp, String id, String initExpr, Map<String, Object> initArgs) init a component form by expression, it only execute oncevoidaddFormLoadBindings(org.zkoss.zk.ui.Component comp, String id, String loadExpr, String[] beforeCmds, String[] afterCmds, Map<String, Object> bindingArgs) Add new form-load-bindings.voidaddFormSaveBindings(org.zkoss.zk.ui.Component comp, String id, String saveExpr, String[] beforeCmds, String[] afterCmds, Map<String, Object> bindingArgs, String validatorExpr, Map<String, Object> validatorArgs) Add new form-save-bindings.voidaddGlobalCommandBinding(org.zkoss.zk.ui.Component comp, String evtnm, String commandExpr, Map<String, Object> commandArgs) Add a new global-command binding.voidaddPropertyInitBinding(org.zkoss.zk.ui.Component comp, String attr, String initExpr, Map<String, Object> initArgs, String converterExpr, Map<String, Object> converterArgs) init a component property by a expression, it only execute oncevoidaddPropertyLoadBindings(org.zkoss.zk.ui.Component comp, String attr, String loadExpr, String[] beforeCmds, String[] afterCmds, Map<String, Object> bindingArgs, String converterExpr, Map<String, Object> converterArgs) Add new property-load-bindings.voidaddPropertySaveBindings(org.zkoss.zk.ui.Component comp, String attr, String saveExpr, String[] beforeCmds, String[] afterCmds, Map<String, Object> bindingArgs, String converterExpr, Map<String, Object> converterArgs, String validatorExpr, Map<String, Object> validatorArgs) Add new property-save-bindings.voidaddReferenceBinding(org.zkoss.zk.ui.Component comp, String attr, String loadExpr, Map<String, Object> bindingArgs) Add a new reference-binding.voidDestroys the binder with a root component and viewModel object.getConverter(String name) Returns the _converter of the given _converter name.Returns theBindEvaluatorXused by this Binder.getValidator(String name) Returns the _validator of the given _validator name.org.zkoss.zk.ui.ComponentgetView()Returns associated root component of this binder.Returns associated ViewModel of this binder.voidInitializes the binder with a root component and viewModel object.voidloadComponent(org.zkoss.zk.ui.Component comp, boolean loadinit) Load the load-binding of the component.voidnotifyChange(Object bean, String property) Notify change of the property.voidpostCommand(String command, Map<String, Object> args) post command this binder, binder will queue the command, and fired later.voidremoveBindings(Set<org.zkoss.zk.ui.Component> comps) Remove all managed bindings that associated with the specified components.voidremoveBindings(org.zkoss.zk.ui.Component comp) Remove all managed bindings that associated with the specified component.voidremoveBindings(org.zkoss.zk.ui.Component comp, String key) Remove all managed Binding that associated with the specified component and attribute name, event name, or form id.intsendCommand(String command, Map<String, Object> args) send command fired to this binder and process the command immediatelyvoidsetPhaseListener(PhaseListener listener) Sets the associated phase listener to intervene the binding life cycle.voidsetTemplate(org.zkoss.zk.ui.Component comp, String attr, String templateExpr, Map<String, Object> templateArgs) set template to a component property by an expressionvoidsetViewModel(Object viewModel) Sets associated ViewModel of this binder.
-
Field Details
-
ZKBIND
Component annotation of ZKBind- See Also:
-
RENDERER
Attribute ofZKBINDannotation, the special renderer for binding- See Also:
-
LOAD_EVENT
Attribute ofZKBINDannotation, the load trigger event; meaningful only when ACCESS is "both" or "load" or not found(default to "load").- See Also:
-
SAVE_EVENT
Attribute ofZKBINDannotation, the save trigger event; meaningful only when ACCESS is "both" or "save".- See Also:
-
ACCESS
Attribute ofZKBINDannotation, the access direction: can be "both", "save", "load"; default to "load" if not found- See Also:
-
CONVERTER
Attribute ofZKBINDannotation, the system converter for special properties. e.g. SelectedItem in listbox. see SelectedListitemConverter.java- See Also:
-
VALIDATOR
Attribute ofZKBINDannotation, the system validator for special properties.- See Also:
-
LOAD_REPLACEMENT
Attribute ofZKBINDannotation, the load replacement ; e.g. value of textbox, it loads to rawValue- See Also:
-
LOAD_TYPE
Attribute ofZKBINDannotation, the type of attribute for loading; e.g. rawValue of textbox is java.lang.String- See Also:
-
SAVE_REPLACEMENT
Attribute ofZKBINDannotation, the save replacement ; e.g. selectedItem of selectbox, it save the value selectedIndex (via converter) to bean- See Also:
-
COMMAND_SUCCESS
static final int COMMAND_SUCCESSIndicates the doing command is successful.- Since:
- 8.0.1
- See Also:
-
COMMAND_FAIL_VALIDATE
static final int COMMAND_FAIL_VALIDATEIndicates the doing command is failure with some validation errors.- Since:
- 8.0.1
- See Also:
-
-
Method Details
-
init
Initializes the binder with a root component and viewModel object. You should never call this if you useAnnotateBinderand zk annotation- Parameters:
root- root component of binderviewModel- viewModel objectinitArgs- args key-value pairs for initial, nullable- Since:
- 6.0.1
-
destroy
Destroys the binder with a root component and viewModel object. You should never call this if you useAnnotateBinderand zk annotation- Parameters:
root- root component of binderviewModel- viewModel object- Since:
- 8.5.2
-
loadComponent
void loadComponent(org.zkoss.zk.ui.Component comp, boolean loadinit) Load the load-binding of the component.
By calling this method, all load-bindings in the component (including load-bindings in its descendant) will reload the value to components.- Parameters:
comp- the component to reloadloadinit- true if should also load the init-binding
-
getEvaluatorX
BindEvaluatorX getEvaluatorX()Returns theBindEvaluatorXused by this Binder.- Returns:
- the EvaluatorX.
-
addCommandBinding
void addCommandBinding(org.zkoss.zk.ui.Component comp, String evtnm, String commandExpr, Map<String, Object> commandArgs) Add a new command binding.- Parameters:
comp- the associated componentevtnm- the associated component event namecommandExpr- the command expressioncommandArgs- other key-value pairs pairs for command
-
addGlobalCommandBinding
void addGlobalCommandBinding(org.zkoss.zk.ui.Component comp, String evtnm, String commandExpr, Map<String, Object> commandArgs) Add a new global-command binding.- Parameters:
comp- the associated componentevtnm- the associated component event namecommandExpr- the command expressioncommandArgs- other key-value pairs pairs for command
-
setTemplate
void setTemplate(org.zkoss.zk.ui.Component comp, String attr, String templateExpr, Map<String, Object> templateArgs) set template to a component property by an expression- Parameters:
comp- the associated component, must not nullattr- the associated attribute of the component; ex label, style, must not nulltemplateExpr- template expression, must not nulltemplateArgs- args key-value pairs for template, nullable
-
addPropertyInitBinding
void addPropertyInitBinding(org.zkoss.zk.ui.Component comp, String attr, String initExpr, Map<String, Object> initArgs, String converterExpr, Map<String, Object> converterArgs) init a component property by a expression, it only execute once- Parameters:
comp- the associated component, must not nullattr- the associated attribute of the component; ex label, style, must not nullinitExpr- init expression, must not nullinitArgs- args key-value pairs for initial, nullableconverterExpr- the converter expression, nullableconverterArgs- args key-value pairs for converter, nullable
-
addPropertyLoadBindings
void addPropertyLoadBindings(org.zkoss.zk.ui.Component comp, String attr, String loadExpr, String[] beforeCmds, String[] afterCmds, Map<String, Object> bindingArgs, String converterExpr, Map<String, Object> converterArgs) Add new property-load-bindings. It creates a prompt|conditional property-load-binding depends on beforeCmds and afterCmds. If both beforeCmds and afterCmds are null or empty, it create a prompt binding.- Parameters:
comp- the associated component, must not nullattr- the associated attribute of the component; ex label, style, must not nullloadExpr- load expression, must not nullbeforeCmds- load before these commands, the command here is not a EL expression. nullableafterCmds- load after these commands, the command here is not a EL expression. nullablebindingArgs- args key-value pairs for this binding, nullableconverterExpr- the converter expression, nullableconverterArgs- args key-value pairs for converter, nullable
-
addPropertySaveBindings
void addPropertySaveBindings(org.zkoss.zk.ui.Component comp, String attr, String saveExpr, String[] beforeCmds, String[] afterCmds, Map<String, Object> bindingArgs, String converterExpr, Map<String, Object> converterArgs, String validatorExpr, Map<String, Object> validatorArgs) Add new property-save-bindings. It creates a prompt|conditional property-save-binding depends on beforeCmds and afterCmds. If both beforeCmds and afterCmds are null or empty, it create a prompt binding.- Parameters:
comp- the associated component, must not nullattr- the associated attribute of the component; ex value, check, must not nullsaveExpr- save expression, nullablebeforeCmds- save before these commands, the command here is not a EL expression. nullableafterCmds- save after these commands, the command here is not a EL expression. nullablebindingArgs- args key-value pairs for this binding, nullableconverterExpr- the converter expression, nullableconverterArgs- args key-value pairs for converter, nullablevalidatorExpr- the converter expression, nullablevalidatorArgs- args key-value pairs for validator, nullable
-
addFormInitBinding
void addFormInitBinding(org.zkoss.zk.ui.Component comp, String id, String initExpr, Map<String, Object> initArgs) init a component form by expression, it only execute once- Parameters:
comp- the associated component, must not nullid- the form id, must not nullinitExpr- init expression, nullableinitArgs- args key-value pairs for this init, nullable
-
addFormLoadBindings
void addFormLoadBindings(org.zkoss.zk.ui.Component comp, String id, String loadExpr, String[] beforeCmds, String[] afterCmds, Map<String, Object> bindingArgs) Add new form-load-bindings. It create a prompt|conditional form-load-binding depends on beforeCmds and afterCmds. If both beforeCmds and afterCmds are null or empty, it create a prompt binding.- Parameters:
comp- the associated component, must not nullid- the form id, must not nullloadExpr- load expression, nullablebeforeCmds- load before these commands, the command here is not a EL expression. nullableafterCmds- load after these commands, the command here is not a EL expression. nullablebindingArgs- args key-value pairs for this binding, nullable
-
addFormSaveBindings
void addFormSaveBindings(org.zkoss.zk.ui.Component comp, String id, String saveExpr, String[] beforeCmds, String[] afterCmds, Map<String, Object> bindingArgs, String validatorExpr, Map<String, Object> validatorArgs) Add new form-save-bindings. It create a conditional form-save-binding depends on beforeCmds and afterCmds. Since form-save-binding is always triggered by command, if both beforeCmds and afterCmds are null or empty, it throws an exception.- Parameters:
comp- the associated component, must not nullid- the form id, must not nullsaveExpr- save expression, nullablebeforeCmds- save before these commands, the command here is not a EL expression. nullableafterCmds- save after these commands, the command here is not a EL expression. nullablebindingArgs- args key-value pairs for this binding, nullablevalidatorExpr- the converter expression, nullablevalidatorArgs- args key-value pairs for validator, nullable- Throws:
IllegalArgumentException- if beforeCmds or afterCmds are both null or empty
-
addChildrenInitBinding
void addChildrenInitBinding(org.zkoss.zk.ui.Component comp, String initExpr, Map<String, Object> initArgs, String converterExpr, Map<String, Object> converterArgs) init children of a component by an expression, it only execute once- Parameters:
comp- the associated component, must not nullinitExpr- init expression, must not nullinitArgs- args key-value pairs for initial, nullableconverterExpr- the converter expression, nullableconverterArgs- args key-value pairs for converter, nullable- Since:
- 6.0.1
-
addChildrenLoadBindings
void addChildrenLoadBindings(org.zkoss.zk.ui.Component comp, String loadExpr, String[] beforeCmds, String[] afterCmds, Map<String, Object> bindingArgs, String converterExpr, Map<String, Object> converterArgs) Add new children-load-bindings. It creates a prompt|conditional children-load-binding depends on beforeCmds and afterCmds. If both beforeCmds and afterCmds are null or empty, it create a prompt binding.- Parameters:
comp- the associated component, must not nullloadExpr- load expression, must not nullbeforeCmds- load before these commands, the command here is not a EL expression. nullableafterCmds- load after these commands, the command here is not a EL expression. nullablebindingArgs- args key-value pairs for this binding, nullableconverterExpr- the converter expression, nullableconverterArgs- args key-value pairs for converter, nullable- Since:
- 6.0.1
-
addReferenceBinding
void addReferenceBinding(org.zkoss.zk.ui.Component comp, String attr, String loadExpr, Map<String, Object> bindingArgs) Add a new reference-binding. It creates an attribute as the reference of the expression in the component.- Parameters:
comp- the associated component, must not nullattr- the name of reference that stored in the component; ex myval, must not nullloadExpr- load expression, must not nullbindingArgs- args key-value pairs for this binding, nullable- Since:
- 6.0.1
-
removeBindings
void removeBindings(org.zkoss.zk.ui.Component comp) Remove all managed bindings that associated with the specified component.- Parameters:
comp-
-
removeBindings
Remove all managed bindings that associated with the specified components.- Parameters:
comps-- Since:
- 7.0.2
-
removeBindings
Remove all managed Binding that associated with the specified component and attribute name, event name, or form id.- Parameters:
comp- the associated componentkey- the associated attribute name, event name, or form id
-
getConverter
Returns the _converter of the given _converter name.- Parameters:
name- _converter name- Returns:
- the _converter of the given _converter name.
-
getValidator
Returns the _validator of the given _validator name.- Parameters:
name- _validator name- Returns:
- the _validator of the given _validator name.
-
notifyChange
Notify change of the property.- Parameters:
bean- the backing bean object.property- the property of the bean that change the value
-
sendCommand
send command fired to this binder and process the command immediately- Parameters:
command- command nameargs- , arguments when notifying this command, it will be passed as a arguments of execution method of vm- Returns:
- the result of the doCommand, COMMAND_SUCCESS or COMMAND_FAIL_VALIDATE (since 8.0.1)
-
postCommand
post command this binder, binder will queue the command, and fired later.- Parameters:
command- command nameargs- , arguments when notifying this command, it will be passed as a arguments of execution method of vm
-
getViewModel
Object getViewModel()Returns associated ViewModel of this binder.- Returns:
- associated ViewModel of this binder.
-
setViewModel
Sets associated ViewModel of this binder.- Parameters:
viewModel- the associated view model of this binder.
-
setPhaseListener
Sets the associated phase listener to intervene the binding life cycle.- Parameters:
listener- the associated phase listener.
-
getView
org.zkoss.zk.ui.Component getView()Returns associated root component of this binder.- Returns:
- associated root component of this binder.
-