org.springframework.richclient.form.binding.support
Class AbstractBinderSelectionStrategy

Show UML class diagram
java.lang.Object
  extended by org.springframework.richclient.form.binding.support.AbstractBinderSelectionStrategy
All Implemented Interfaces:
InitializingBean, ApplicationContextAware, BinderSelectionStrategy
Direct Known Subclasses:
SwingBinderSelectionStrategy

public abstract class AbstractBinderSelectionStrategy
extends Object
implements BinderSelectionStrategy, ApplicationContextAware, InitializingBean

Default implementation of BinderSelectionStrategy. Provides for registering of binders by control type, property type and property name.

Author:
Oliver Hutchison, Jim Moore

Constructor Summary
AbstractBinderSelectionStrategy(Class defaultControlType)
           
 
Method Summary
 void afterPropertiesSet()
           
protected  Binder findBinderByControlType(Class controlType)
          Try to find a binder for the provided controlType.
protected  Binder findBinderByPropertyName(Class parentObjectType, String propertyName)
          Try to find a binder for the provided parentObjectType and propertyName.
protected  Binder findBinderByPropertyType(Class propertyType)
          Try to find a binder for the provided propertyType.
protected  ApplicationContext getApplicationContext()
           
protected  Class getPropertyType(FormModel formModel, String formPropertyPath)
           
protected  boolean isEnumeration(FormModel formModel, String formPropertyPath)
           
protected  void registerBinderForControlType(Class controlType, Binder binder)
           
protected  void registerBinderForPropertyName(Class parentObjectType, String propertyName, Binder binder)
           
protected  void registerBinderForPropertyType(Class propertyType, Binder binder)
           
protected abstract  void registerDefaultBinders()
          Register the default set of binders.
 Binder selectBinder(Class controlType, FormModel formModel, String propertyName)
          Returns a binder that is capable of binding the provided control type to the provided form model and property name.
 Binder selectBinder(FormModel formModel, String propertyName)
          Returns a binder for the provided form model and property name.
 void setApplicationContext(ApplicationContext applicationContext)
           
 void setBinderForPropertyName(Properties binder)
          Create/link a Binder to a propertyName from the given Properties.
 void setBindersForControlTypes(Map binders)
          Registers control type binders by extracting the key and value from each entry in the provided map using the key to specify the property type and the value to specify the binder.
 void setBindersForPropertyNames(List binders)
          Add a list of binders that are bound to propertyNames.
 void setBindersForPropertyTypes(Map binders)
          Registers property type binders by extracting the key and value from each entry in the provided map using the key to specify the property type and the value to specify the binder.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractBinderSelectionStrategy

public AbstractBinderSelectionStrategy(Class defaultControlType)
Method Detail

selectBinder

public Binder selectBinder(FormModel formModel,
                           String propertyName)
Description copied from interface: BinderSelectionStrategy
Returns a binder for the provided form model and property name.

Specified by:
selectBinder in interface BinderSelectionStrategy
Parameters:
formModel - the form model which contains the property to be bound
propertyName - the name of the property to be bound
Returns:
the Binder (never null). This binder must be capable of generating it's own control to bind to.

selectBinder

public Binder selectBinder(Class controlType,
                           FormModel formModel,
                           String propertyName)
Description copied from interface: BinderSelectionStrategy
Returns a binder that is capable of binding the provided control type to the provided form model and property name.

Specified by:
selectBinder in interface BinderSelectionStrategy
Parameters:
controlType - the type of the control to be bound
formModel - the form model which contains the property to be bound
propertyName - the name of the property to be bound
Returns:
the Binder (never null). This binder must be capable of binding to a pre-created control that is of the specified controlType.

registerDefaultBinders

protected abstract void registerDefaultBinders()
Register the default set of binders. This method is called on construction.

See Also:
registerBinderForPropertyName(Class, String, Binder), registerBinderForPropertyType(Class, Binder), registerBinderForControlType(Class, Binder)

findBinderByPropertyName

protected Binder findBinderByPropertyName(Class parentObjectType,
                                          String propertyName)
Try to find a binder for the provided parentObjectType and propertyName. If no direct match found try to find binder for any superclass of the provided objectType which also has the same propertyName.


findBinderByPropertyType

protected Binder findBinderByPropertyType(Class propertyType)
Try to find a binder for the provided propertyType. If no direct match found, try to find binder for closest superclass of the given control type.


findBinderByControlType

protected Binder findBinderByControlType(Class controlType)
Try to find a binder for the provided controlType. If no direct match found, try to find binder for closest superclass of the given control type.


registerBinderForPropertyName

protected void registerBinderForPropertyName(Class parentObjectType,
                                             String propertyName,
                                             Binder binder)

setBindersForPropertyNames

public void setBindersForPropertyNames(List binders)
Add a list of binders that are bound to propertyNames. Each element in the list should be a Properties element describing the binder and propertyName. For more information about the structure of the properties see setBinderForPropertyName(Properties).

<list>
<props>
<prop key="...">...</prop>
<!-- More info in docs of setBinderForPropertyName(Properties)-->
</props>
</list>

Parameters:
binders - List of Properties elements
See Also:
setBinderForPropertyName(Properties)

setBinderForPropertyName

public void setBinderForPropertyName(Properties binder)
Create/link a Binder to a propertyName from the given Properties.

The used keys are:

The first two keys are mandatory in combination with one of the two latter (binder or binderRef) The following two cases can be used to define a binder/propertyName combination:

<props>
<prop key="objectClass">mypackage.MyBean</prop>
<prop key="propertyName">myProperty</prop>
<prop key="binder">mypackage.MyBinder</prop>
</props>

<props>
<prop key="objectClass">mypackage.MyBean</prop>
<prop key="propertyName">myProperty</prop>
<prop key="binderRef">myBinderBeanId</prop>
<!-- myBinderBeanId identifies a bean defined elsewhere-->
</props>

Parameters:
binder - The Properties object containing the correct keys.

registerBinderForPropertyType

protected void registerBinderForPropertyType(Class propertyType,
                                             Binder binder)

setBindersForPropertyTypes

public void setBindersForPropertyTypes(Map binders)
Registers property type binders by extracting the key and value from each entry in the provided map using the key to specify the property type and the value to specify the binder.

Binders specified in the provided map will override any binders previously registered for the same property type.

Parameters:
binders - the map containing the entries to register; keys must be of type Class and values of type Binder.

registerBinderForControlType

protected void registerBinderForControlType(Class controlType,
                                            Binder binder)

setBindersForControlTypes

public void setBindersForControlTypes(Map binders)
Registers control type binders by extracting the key and value from each entry in the provided map using the key to specify the property type and the value to specify the binder.

Binders specified in the provided map will override any binders previously registered for the same control type.

Parameters:
binders - the map containing the entries to register; keys must be of type Class and values of type Binder.

getPropertyType

protected Class getPropertyType(FormModel formModel,
                                String formPropertyPath)

isEnumeration

protected boolean isEnumeration(FormModel formModel,
                                String formPropertyPath)

setApplicationContext

public void setApplicationContext(ApplicationContext applicationContext)
Specified by:
setApplicationContext in interface ApplicationContextAware

getApplicationContext

protected ApplicationContext getApplicationContext()

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception


Copyright © 2004-2009 The Spring Framework. All Rights Reserved.