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 Details

    • ZKBIND

      static final String ZKBIND
      Component annotation of ZKBind
      See Also:
    • RENDERER

      static final String RENDERER
      Attribute of ZKBIND annotation, the special renderer for binding
      See Also:
    • LOAD_EVENT

      static final String LOAD_EVENT
      Attribute of ZKBIND annotation, the load trigger event; meaningful only when ACCESS is "both" or "load" or not found(default to "load").
      See Also:
    • SAVE_EVENT

      static final String SAVE_EVENT
      Attribute of ZKBIND annotation, the save trigger event; meaningful only when ACCESS is "both" or "save".
      See Also:
    • ACCESS

      static final String ACCESS
      Attribute of ZKBIND annotation, the access direction: can be "both", "save", "load"; default to "load" if not found
      See Also:
    • CONVERTER

      static final String CONVERTER
      Attribute of ZKBIND annotation, the system converter for special properties. e.g. SelectedItem in listbox. see SelectedListitemConverter.java
      See Also:
    • VALIDATOR

      static final String VALIDATOR
      Attribute of ZKBIND annotation, the system validator for special properties.
      See Also:
    • LOAD_REPLACEMENT

      static final String LOAD_REPLACEMENT
      Attribute of ZKBIND annotation, the load replacement ; e.g. value of textbox, it loads to rawValue
      See Also:
    • LOAD_TYPE

      static final String LOAD_TYPE
      Attribute of ZKBIND annotation, the type of attribute for loading; e.g. rawValue of textbox is java.lang.String
      See Also:
    • SAVE_REPLACEMENT

      static final String SAVE_REPLACEMENT
      Attribute of ZKBIND annotation, 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_SUCCESS
      Indicates the doing command is successful.
      Since:
      8.0.1
      See Also:
    • COMMAND_FAIL_VALIDATE

      static final int COMMAND_FAIL_VALIDATE
      Indicates the doing command is failure with some validation errors.
      Since:
      8.0.1
      See Also:
  • Method Details

    • init

      void init(org.zkoss.zk.ui.Component root, Object viewModel, Map<String,Object> initArgs)
      Initializes the binder with a root component and viewModel object. You should never call this if you use AnnotateBinder and zk annotation
      Parameters:
      root - root component of binder
      viewModel - viewModel object
      initArgs - args key-value pairs for initial, nullable
      Since:
      6.0.1
    • destroy

      void destroy(org.zkoss.zk.ui.Component root, Object viewModel)
      Destroys the binder with a root component and viewModel object. You should never call this if you use AnnotateBinder and zk annotation
      Parameters:
      root - root component of binder
      viewModel - 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 reload
      loadinit - true if should also load the init-binding
    • getEvaluatorX

      BindEvaluatorX getEvaluatorX()
      Returns the BindEvaluatorX used 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 component
      evtnm - the associated component event name
      commandExpr - the command expression
      commandArgs - 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 component
      evtnm - the associated component event name
      commandExpr - the command expression
      commandArgs - 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 null
      attr - the associated attribute of the component; ex label, style, must not null
      templateExpr - template expression, must not null
      templateArgs - 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 null
      attr - the associated attribute of the component; ex label, style, must not null
      initExpr - init expression, must not null
      initArgs - args key-value pairs for initial, nullable
      converterExpr - the converter expression, nullable
      converterArgs - 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 null
      attr - the associated attribute of the component; ex label, style, must not null
      loadExpr - load expression, must not null
      beforeCmds - load before these commands, the command here is not a EL expression. nullable
      afterCmds - load after these commands, the command here is not a EL expression. nullable
      bindingArgs - args key-value pairs for this binding, nullable
      converterExpr - the converter expression, nullable
      converterArgs - 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 null
      attr - the associated attribute of the component; ex value, check, must not null
      saveExpr - save expression, nullable
      beforeCmds - save before these commands, the command here is not a EL expression. nullable
      afterCmds - save after these commands, the command here is not a EL expression. nullable
      bindingArgs - args key-value pairs for this binding, nullable
      converterExpr - the converter expression, nullable
      converterArgs - args key-value pairs for converter, nullable
      validatorExpr - the converter expression, nullable
      validatorArgs - 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 null
      id - the form id, must not null
      initExpr - init expression, nullable
      initArgs - 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 null
      id - the form id, must not null
      loadExpr - load expression, nullable
      beforeCmds - load before these commands, the command here is not a EL expression. nullable
      afterCmds - load after these commands, the command here is not a EL expression. nullable
      bindingArgs - 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 null
      id - the form id, must not null
      saveExpr - save expression, nullable
      beforeCmds - save before these commands, the command here is not a EL expression. nullable
      afterCmds - save after these commands, the command here is not a EL expression. nullable
      bindingArgs - args key-value pairs for this binding, nullable
      validatorExpr - the converter expression, nullable
      validatorArgs - 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 null
      initExpr - init expression, must not null
      initArgs - args key-value pairs for initial, nullable
      converterExpr - the converter expression, nullable
      converterArgs - 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 null
      loadExpr - load expression, must not null
      beforeCmds - load before these commands, the command here is not a EL expression. nullable
      afterCmds - load after these commands, the command here is not a EL expression. nullable
      bindingArgs - args key-value pairs for this binding, nullable
      converterExpr - the converter expression, nullable
      converterArgs - 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 null
      attr - the name of reference that stored in the component; ex myval, must not null
      loadExpr - load expression, must not null
      bindingArgs - 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

      void removeBindings(Set<org.zkoss.zk.ui.Component> comps)
      Remove all managed bindings that associated with the specified components.
      Parameters:
      comps -
      Since:
      7.0.2
    • removeBindings

      void removeBindings(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.
      Parameters:
      comp - the associated component
      key - the associated attribute name, event name, or form id
    • getConverter

      Converter getConverter(String name)
      Returns the _converter of the given _converter name.
      Parameters:
      name - _converter name
      Returns:
      the _converter of the given _converter name.
    • getValidator

      Validator getValidator(String name)
      Returns the _validator of the given _validator name.
      Parameters:
      name - _validator name
      Returns:
      the _validator of the given _validator name.
    • notifyChange

      void notifyChange(Object bean, String property)
      Notify change of the property.
      Parameters:
      bean - the backing bean object.
      property - the property of the bean that change the value
    • sendCommand

      int sendCommand(String command, Map<String,Object> args)
      send command fired to this binder and process the command immediately
      Parameters:
      command - command name
      args - , 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

      void postCommand(String command, Map<String,Object> args)
      post command this binder, binder will queue the command, and fired later.
      Parameters:
      command - command name
      args - , 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

      void setViewModel(Object viewModel)
      Sets associated ViewModel of this binder.
      Parameters:
      viewModel - the associated view model of this binder.
    • setPhaseListener

      void setPhaseListener(PhaseListener listener)
      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.