info.joseluismartin.gui.bind
Class AbstractBinder

java.lang.Object
  extended by info.joseluismartin.gui.bind.AbstractBinder
All Implemented Interfaces:
PropertyBinder, Binder<Object>, ModelHolder<Object>
Direct Known Subclasses:
CollectionPersistentServiceBinder, ComboBinder, ControlBinder, LabelBinder, ListBinder, SelectorBinder, TextComponentBinder, ToggleButtonBinder, ViewBinder

public abstract class AbstractBinder
extends Object
implements PropertyBinder

Base class for Binders. Implement doBind() to do the binding. Dereference ModelHolders when setting its as binded model.

Author:
Jose Luis Martin - (jlm@joseluismartin.info)

Field Summary
protected  Object component
          component object
protected  Object oldValue
          last value, used to revert o detect cicles
protected  String propertyName
          binded property name
protected  boolean readOnly
          if true, binding is readOnly, ie from model to control
 
Constructor Summary
AbstractBinder()
           
 
Method Summary
 void bind(Object component, String propertyName, Object model)
          Bind changes on component to a model property
 void bind(Object component, String propertyName, Object model, boolean readOnly)
          Bind changes on component to a model property
protected  org.springframework.validation.BindingResult createBindingResult()
          Create a new Binding result, override to set nested paths on complex binders
protected  void doBind()
          Hook method to do bind via Component Listeners By default, do nothing
protected abstract  void doRefresh()
           
protected abstract  void doUpdate()
           
 org.springframework.validation.BindingResult getBindingResult()
          Get binding result
 Object getComponent()
           
 Object getModel()
          Gets model
protected  Object getOldValue()
           
 String getPropertyName()
          return property name
protected  Object getValue()
          Get value from model
 void refresh()
          Update Component from model
 void setComponent(Object component)
           
 void setModel(Object model)
          Sets model
protected  void setOldValue(Object oldValue)
           
 void setPropertyName(String propertyName)
           
protected  void setValue(Object value)
          Set value on binded object using the property name.
 void update()
          Update Model from Component
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

propertyName

protected String propertyName
binded property name


oldValue

protected Object oldValue
last value, used to revert o detect cicles


component

protected Object component
component object


readOnly

protected boolean readOnly
if true, binding is readOnly, ie from model to control

Constructor Detail

AbstractBinder

public AbstractBinder()
Method Detail

bind

public final void bind(Object component,
                       String propertyName,
                       Object model)
Bind changes on component to a model property

Specified by:
bind in interface PropertyBinder
Parameters:
component - component to bind
propertyName - the property name to bind
model - model to bind.

bind

public final void bind(Object component,
                       String propertyName,
                       Object model,
                       boolean readOnly)
Bind changes on component to a model property

Specified by:
bind in interface PropertyBinder
Parameters:
component - component to bind
propertyName - the property name to bind
model - model to bind.
readOnly - if true, the binding is readOnly, ie from model to control.

doBind

protected void doBind()
Hook method to do bind via Component Listeners By default, do nothing

Parameters:
component - Component to bind

refresh

public final void refresh()
Description copied from interface: Binder
Update Component from model

Specified by:
refresh in interface Binder<Object>

update

public final void update()
Description copied from interface: Binder
Update Model from Component

Specified by:
update in interface Binder<Object>

createBindingResult

protected org.springframework.validation.BindingResult createBindingResult()
Create a new Binding result, override to set nested paths on complex binders

Returns:
a new instance of BindingResult for this model

doRefresh

protected abstract void doRefresh()

doUpdate

protected abstract void doUpdate()

setValue

protected void setValue(Object value)
Set value on binded object using the property name.

Parameters:
value - the value to set

getValue

protected Object getValue()
Get value from model

Returns:
model value

getPropertyName

public String getPropertyName()
Description copied from interface: PropertyBinder
return property name

Specified by:
getPropertyName in interface PropertyBinder
Returns:
the property name

setPropertyName

public void setPropertyName(String propertyName)

getOldValue

protected Object getOldValue()

setOldValue

protected void setOldValue(Object oldValue)

getModel

public Object getModel()
Description copied from interface: ModelHolder
Gets model

Specified by:
getModel in interface ModelHolder<Object>
Returns:
the model

setModel

public void setModel(Object model)
Description copied from interface: ModelHolder
Sets model

Specified by:
setModel in interface ModelHolder<Object>

getComponent

public Object getComponent()
Specified by:
getComponent in interface PropertyBinder
Returns:
the component

setComponent

public void setComponent(Object component)
Parameters:
component - the component to set

getBindingResult

public org.springframework.validation.BindingResult getBindingResult()
Description copied from interface: Binder
Get binding result

Specified by:
getBindingResult in interface Binder<Object>
Returns:
the binding result


Copyright © 2013 JDAL. All Rights Reserved.