|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.binding.value.support.AbstractPropertyChangePublisher
org.springframework.binding.form.support.AbstractFormModel
public abstract class AbstractFormModel
Base implementation of HierarchicalFormModel and ConfigurableFormModel subclasses need only implement the 4 value model interception methods.
Nested Class Summary | |
---|---|
protected class |
AbstractFormModel.ChildStateChangeHandler
Listener to be registered on properties of child form models and other valueModels. |
protected static class |
AbstractFormModel.ConvertingValueModelKey
Class for keys in the convertingValueModels map. |
protected class |
AbstractFormModel.ParentStateChangeHandler
Listener to be registered on properties of the parent form model. |
Field Summary | |
---|---|
protected PropertyChangeListener |
childStateChangeHandler
|
protected PropertyChangeListener |
parentStateChangeHandler
|
Fields inherited from class org.springframework.binding.value.support.AbstractPropertyChangePublisher |
---|
logger |
Fields inherited from interface org.springframework.binding.form.FormModel |
---|
COMMITTABLE_PROPERTY, DIRTY_PROPERTY, ENABLED_PROPERTY, READONLY_PROPERTY |
Fields inherited from interface org.springframework.richclient.core.Authorizable |
---|
AUTHORIZED_PROPERTY |
Constructor Summary | |
---|---|
protected |
AbstractFormModel()
|
protected |
AbstractFormModel(MutablePropertyAccessStrategy propertyAccessStrategy,
boolean buffered)
|
protected |
AbstractFormModel(Object domainObject)
|
|
AbstractFormModel(Object domainObject,
boolean buffered)
|
protected |
AbstractFormModel(ValueModel domainObjectHolder,
boolean buffered)
|
Method Summary | |
---|---|
ValueModel |
add(String propertyName)
Add a valueModel for the given property. |
ValueModel |
add(String formProperty,
ValueModel valueModel)
Add the given valueModel as wrapper for the given property. |
ValueModel |
add(String propertyName,
ValueModel valueModel,
FieldMetadata metadata)
Add the given valueModel as wrapper for the given property. |
void |
addChild(HierarchicalFormModel child)
Add child to this FormModel. |
void |
addCommitListener(CommitListener listener)
Adds the specified listener to the list if listeners notified when a commit happens. |
ValueModel |
addMethod(String propertyMethodName,
String derivedFromProperty)
Add a valueModel that holds a derived value computed by invoking the given method with the given property as argument on the formModel. |
ValueModel |
addMethod(String propertyMethodName,
String[] derivedFromProperties)
Add a valueModel that holds a derived value computed by invoking the given method with a number of other properties as arguments on the formModel. |
protected void |
childStateChanged(PropertyChangeEvent evt)
Events from the child form model or value models that have side-effects on this form model should be handled here. |
void |
commit()
Commits any changes buffered by the form property value models into the current form backing object. |
protected void |
committableUpdated()
Fires the necessary property change event for changes to the committable property. |
protected ValueModel |
createConvertingValueModel(String formProperty,
Class targetClass)
|
protected ValueModel |
createValueModel(String formProperty)
Creates a new value mode for the the given property. |
protected void |
dirtyUpdated()
Fires the necessary property change event for changes to the dirty property. |
protected void |
enabledUpdated()
Fires the necessary property change event for changes to the enabled property. |
FormModel[] |
getChildren()
Returns an array of child form models. |
org.springframework.binding.convert.ConversionService |
getConversionService()
|
Class |
getDefaultInstanceClass()
|
FieldFace |
getFieldFace(String field)
FIXME: this should be on the FieldMetadata class |
protected FieldFaceSource |
getFieldFaceSource()
Returns the FieldFaceSource that should be used to obtain FieldFace instances for this form model. |
FieldMetadata |
getFieldMetadata(String propertyName)
Returns the metadata for the given form field. |
Set |
getFieldNames()
Returns the fields that are used by this formModel. |
Object |
getFormObject()
Returns the object currently backing this form. |
ValueModel |
getFormObjectHolder()
Returns the value model which holds the object currently backing this form. |
MutablePropertyAccessStrategy |
getFormObjectPropertyAccessStrategy()
|
String |
getId()
Returns the id that is used to identify this form model. |
HierarchicalFormModel |
getParent()
Returns the parent form model or null of there is none. |
PropertyAccessStrategy |
getPropertyAccessStrategy()
|
ValueModel |
getValueModel(String formProperty)
Returns a value model that holds the value of the specified form property. |
ValueModel |
getValueModel(String formProperty,
Class targetClass)
Returns a type converting value model for the given form property. |
protected void |
handleSetNullFormObject()
|
boolean |
hasValueModel(String formProperty)
Returns true if the form has a value model for the provided property name. |
boolean |
isAuthorized()
Check if the form has the correct authorization and can be edited. |
boolean |
isBuffered()
Does this form model buffer changes? |
boolean |
isCommittable()
Returns true if the changes held by this form are able to be committed. |
boolean |
isDirty()
Returns true if this formModel or any of its children has
dirty valueModels. |
boolean |
isEnabled()
A form can be enabled/disabled which reflects a global state on the associated valueModels and their metaData. |
boolean |
isReadOnly()
A form can be set as readOnly which reflects a global state on the valueModels and their metaData. |
protected void |
parentStateChanged(PropertyChangeEvent evt)
Events from the parent form model that have side-effects on this form model should be handled here. |
protected void |
postCommit()
Hook for subclasses to intercept after a successful commit has finished. |
protected abstract void |
postProcessNewConvertingValueModel(String formProperty,
Class targetClass,
ValueModel valueModel)
Provides a hook for subclasses to perform some processing after a new converting value model has been added to this form model. |
protected abstract void |
postProcessNewValueModel(String formProperty,
ValueModel valueModel)
Provides a hook for subclasses to perform some processing after a new value model has been added to this form model. |
protected void |
preCommit()
Hook for subclasses to intercept before a commit. |
protected void |
prepareValueModel(ValueModel valueModel)
Prepare the provided value model for use in this form model. |
protected abstract ValueModel |
preProcessNewConvertingValueModel(String formProperty,
Class targetClass,
ValueModel formValueModel)
Provides a hook for subclasses to optionally decorate a new converting value model added to this form model. |
protected abstract ValueModel |
preProcessNewValueModel(String formProperty,
ValueModel formValueModel)
Provides a hook for subclasses to optionally decorate a new value model added to this form model. |
protected void |
readOnlyUpdated()
Fires the necessary property change event for changes to the readOnly property. |
void |
registerPropertyConverter(String propertyName,
org.springframework.binding.convert.Converter toConverter,
org.springframework.binding.convert.Converter fromConverter)
Register converters for a given property name. |
void |
removeChild(HierarchicalFormModel child)
Remove a child FormModel. |
void |
removeCommitListener(CommitListener listener)
Removes the specified listener to the list if listeners notified when a commit happens. |
void |
removeParent()
Remove the parent form model |
void |
reset()
Complex forms with parent-child relations can use derived formModels. |
void |
revert()
Revert state. |
void |
setAuthorized(boolean authorized)
Set whether or not the form is authorized and can be edited. |
void |
setConversionService(org.springframework.binding.convert.ConversionService conversionService)
|
void |
setDefaultInstanceClass(Class defaultInstanceClass)
|
void |
setEnabled(boolean enabled)
Set the enabled state of this formModel. |
void |
setFieldFaceSource(FieldFaceSource fieldFaceSource)
Sets the FieldFaceSource that will be used to obtain FieldFace instances. |
void |
setFormObject(Object formObject)
Sets the object currently backing this form. |
void |
setId(String id)
An id to identify this formModel. |
void |
setParent(HierarchicalFormModel parent)
Sets the parent form model. |
void |
setReadOnly(boolean readOnly)
Set the readOnly state of this formModel. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.springframework.binding.value.PropertyChangePublisher |
---|
addPropertyChangeListener, addPropertyChangeListener, removePropertyChangeListener, removePropertyChangeListener |
Field Detail |
---|
protected final PropertyChangeListener parentStateChangeHandler
protected final PropertyChangeListener childStateChangeHandler
Constructor Detail |
---|
protected AbstractFormModel()
protected AbstractFormModel(Object domainObject)
public AbstractFormModel(Object domainObject, boolean buffered)
protected AbstractFormModel(ValueModel domainObjectHolder, boolean buffered)
protected AbstractFormModel(MutablePropertyAccessStrategy propertyAccessStrategy, boolean buffered)
Method Detail |
---|
protected void prepareValueModel(ValueModel valueModel)
valueModel
- to preparepublic String getId()
FormModel
getId
in interface FormModel
public void setId(String id)
ConfigurableFormModel
setId
in interface ConfigurableFormModel
public Object getFormObject()
FormModel
getFormObject
in interface FormModel
public void setFormObject(Object formObject)
FormModel
setFormObject
in interface FormModel
public void setDefaultInstanceClass(Class defaultInstanceClass)
public Class getDefaultInstanceClass()
protected void handleSetNullFormObject()
public ValueModel getFormObjectHolder()
getFormObjectHolder
in interface FormModel
public HierarchicalFormModel getParent()
HierarchicalFormModel
getParent
in interface HierarchicalFormModel
public void setParent(HierarchicalFormModel parent)
setParent
in interface HierarchicalFormModel
public void removeParent()
HierarchicalFormModel
removeParent
in interface HierarchicalFormModel
public FormModel[] getChildren()
HierarchicalFormModel
getChildren
in interface HierarchicalFormModel
public void addChild(HierarchicalFormModel child)
addChild
in interface HierarchicalFormModel
child
- FormModel to add as child.public void removeChild(HierarchicalFormModel child)
removeChild
in interface HierarchicalFormModel
child
- FormModel to remove from childlist.public boolean hasValueModel(String formProperty)
FormModel
hasValueModel
in interface FormModel
public ValueModel getValueModel(String formProperty)
FormModel
getValueModel
in interface FormModel
public ValueModel getValueModel(String formProperty, Class targetClass)
FormModel
getValueModel
in interface FormModel
protected ValueModel createValueModel(String formProperty)
protected ValueModel createConvertingValueModel(String formProperty, Class targetClass)
public void registerPropertyConverter(String propertyName, org.springframework.binding.convert.Converter toConverter, org.springframework.binding.convert.Converter fromConverter)
registerPropertyConverter
in interface FormModel
propertyName
- name of property on which to register converterstoConverter
- Convert from source to target typefromConverter
- Convert from target to source typepublic ValueModel add(String propertyName)
ConfigurableFormModel
add
in interface ConfigurableFormModel
propertyName
- the property to create a valueModel for.
public ValueModel add(String formProperty, ValueModel valueModel)
ConfigurableFormModel
add
in interface ConfigurableFormModel
formProperty
- the property.valueModel
- the valueModel to access the property.
public ValueModel add(String propertyName, ValueModel valueModel, FieldMetadata metadata)
This adds another dimension to the formModel as this makes it possible to provide your own property that is not present on the formObject but does have a valueModel and metadata to bind fields and listen to.
add
in interface ConfigurableFormModel
propertyName
- the property, possibly not bound to the formObject.valueModel
- the valueModel to access the property.metadata
- the metadata for this valueModel.
DerivedValueModel
,
AbstractDerivedValueModel
,
MessageFormatValueModel
protected abstract ValueModel preProcessNewValueModel(String formProperty, ValueModel formValueModel)
protected abstract void postProcessNewValueModel(String formProperty, ValueModel valueModel)
protected abstract ValueModel preProcessNewConvertingValueModel(String formProperty, Class targetClass, ValueModel formValueModel)
protected abstract void postProcessNewConvertingValueModel(String formProperty, Class targetClass, ValueModel valueModel)
public FieldMetadata getFieldMetadata(String propertyName)
FormModel
getFieldMetadata
in interface FormModel
public Set getFieldNames()
getFieldNames
in interface FormModel
public void setFieldFaceSource(FieldFaceSource fieldFaceSource)
If this value is null
the default FieldFaceSource from
ApplicationServices
instance will be used.
protected FieldFaceSource getFieldFaceSource()
public FieldFace getFieldFace(String field)
FormModel
getFieldFace
in interface FormModel
public ValueModel addMethod(String propertyMethodName, String derivedFromProperty)
ConfigurableFormModel
addMethod
in interface ConfigurableFormModel
propertyMethodName
- method to invoke.derivedFromProperty
- property to use as argument.
public ValueModel addMethod(String propertyMethodName, String[] derivedFromProperties)
ConfigurableFormModel
addMethod
in interface ConfigurableFormModel
propertyMethodName
- method to invoke.derivedFromProperties
- a number of properties to use as arguments
on the method.
public org.springframework.binding.convert.ConversionService getConversionService()
public void setConversionService(org.springframework.binding.convert.ConversionService conversionService)
public MutablePropertyAccessStrategy getFormObjectPropertyAccessStrategy()
public PropertyAccessStrategy getPropertyAccessStrategy()
public void commit()
FormModel
commit
in interface FormModel
FormModel.isCommittable()
protected void preCommit()
protected void postCommit()
public void revert()
revert
in interface FormModel
public void reset()
reset
in interface FormModel
FormModel.reset()
public boolean isBuffered()
FormModel
isBuffered
in interface FormModel
public boolean isDirty()
true
if this formModel or any of its children has
dirty valueModels.
isDirty
in interface FormModel
protected void dirtyUpdated()
public void setReadOnly(boolean readOnly)
ConfigurableFormModel
Set the readOnly state of this formModel. All fieldMetaData should take the readOnly state of the formModel into account but should not alter their own enclosed readOnly state.
A formModel in readOnly state can be seen as visual component in which the user can navigate but not alter any values. (Eg editable TextFields)
setReadOnly
in interface ConfigurableFormModel
readOnly
- set to true
if all fields should be set
readOnly.public boolean isReadOnly()
FormModel
isReadOnly
in interface FormModel
true
if this form is readOnly.public boolean isAuthorized()
isAuthorized
in interface Authorizable
true
if this form is authorized and may be edited.public void setAuthorized(boolean authorized)
setAuthorized
in interface Authorizable
authorized
- true
if this form may be edited.protected void readOnlyUpdated()
public void setEnabled(boolean enabled)
ConfigurableFormModel
Set the enabled state of this formModel. All fieldMetaData should take the enabled state of the formModel into account but should not alter their own enclosed enabled state.
A disabled formModel can be compared to a visual component which doesn't respond to any user interaction (grey-out).
setEnabled
in interface ConfigurableFormModel
enabled
- set to true
if the formModel should be
enabled. Set to false
if all fields should be disabled.public boolean isEnabled()
FormModel
true
if this form is enabled.
isEnabled
in interface FormModel
protected void enabledUpdated()
public boolean isCommittable()
FormModel
isCommittable
in interface FormModel
protected void committableUpdated()
public void addCommitListener(CommitListener listener)
FormModel
addCommitListener
in interface FormModel
public void removeCommitListener(CommitListener listener)
FormModel
removeCommitListener
in interface FormModel
protected void parentStateChanged(PropertyChangeEvent evt)
protected void childStateChanged(PropertyChangeEvent evt)
parentStateChanged(PropertyChangeEvent)
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |