info.joseluismartin.gui.bind
Class AutoBinder<T>

java.lang.Object
  extended by info.joseluismartin.gui.bind.AutoBinder<T>
All Implemented Interfaces:
Binder<T>, ModelHolder<T>
Direct Known Subclasses:
SwingBinder

public class AutoBinder<T>
extends Object
implements Binder<T>

Do an automatic binding of a view using reflection. Bind controls with name equals to property names in model.

Since:
1.1
Author:
Jose Luis Martin
See Also:
Binder

Constructor Summary
AutoBinder(ModelHolder<T> view)
          Create an AutoBinder for a View
AutoBinder(Object view, T model)
          Create a Binder for view and model
 
Method Summary
 void bind(String viewField, String propertyName)
           
 org.springframework.validation.BindingResult getBindingResult()
          Return the Binding result
 ControlAccessorFactory getControlAccessorFactory()
           
 Set<String> getIgnoredProperties()
           
 T getModel()
          Gets model
 void ignoreProperties(Collection<? extends String> c)
          Add a Collection of property names to ignore on binding
 void ignoreProperty(String propertyName)
          Add a property name to ignore on binding.
 void refresh()
          Update Component from model
 void setControlAccessorFactory(ControlAccessorFactory controlAccessorFactory)
           
 void setIgnoredProperties(Set<String> ignoredProperties)
           
 void setModel(T model)
          Sets model
 void update()
          Update Model from Component
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AutoBinder

public AutoBinder(ModelHolder<T> view)
Create an AutoBinder for a View

Parameters:
view - View to bind.

AutoBinder

public AutoBinder(Object view,
                  T model)
Create a Binder for view and model

Parameters:
view -
model -
Method Detail

bind

public void bind(String viewField,
                 String propertyName)
          throws UndefinedAccessorException
Throws:
UndefinedAccessorException

refresh

public void refresh()
Update Component from model

Specified by:
refresh in interface Binder<T>

update

public void update()
Update Model from Component

Specified by:
update in interface Binder<T>

getModel

public T getModel()
Gets model

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

setModel

public void setModel(T model)
Sets model

Specified by:
setModel in interface ModelHolder<T>

getControlAccessorFactory

public ControlAccessorFactory getControlAccessorFactory()
Returns:
the controlAccessorFactory

setControlAccessorFactory

public void setControlAccessorFactory(ControlAccessorFactory controlAccessorFactory)
Parameters:
controlAccessorFactory - the controlAccessorFactory to set

ignoreProperty

public void ignoreProperty(String propertyName)
Add a property name to ignore on binding.

Parameters:
propertyName - property name to ignore

getIgnoredProperties

public Set<String> getIgnoredProperties()
Returns:
the ignoredProperties

setIgnoredProperties

public void setIgnoredProperties(Set<String> ignoredProperties)
Parameters:
ignoredProperties - the ignoredProperties to set

ignoreProperties

public void ignoreProperties(Collection<? extends String> c)
Add a Collection of property names to ignore on binding

Parameters:
c - Collection of property names.

getBindingResult

public org.springframework.validation.BindingResult getBindingResult()
Return the Binding result

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


Copyright © 2013 JDAL. All Rights Reserved.