public class DefaultFieldHandler extends Object implements FieldHandler
A default implementation of the FieldHandler
interface.
This class implements all necessary functionality to deal with form fields of different types. It supports both validation and conversion of data. Conversion works in two directions: from a bean property to a representation that can be processed by a GUI widget and vice versa. Validation (on the field and form level) ensures that data entered by the user is syntactically and semantically valid.
To perform its tasks this class makes use of some
Validator
and
Transformer
objects that can be associated with an instance. It ensures that the services
provided by these objects are accessed when necessary. When creating an
instance of this class it must be ensured that the correct validators and
transformers are set; especially the data types they operate on must be
compatible.
Constructor and Description |
---|
DefaultFieldHandler()
Creates a new instance of
DefaultFieldHandler . |
Modifier and Type | Method and Description |
---|---|
protected Object |
fetchFieldData()
Fetches the form field's data directly from the component handler.
|
ComponentHandler<?> |
getComponentHandler()
Returns the component handler.
|
Object |
getData()
Fetches the data of this field.
|
String |
getDisplayName()
Returns the display name.
|
ValidatorWrapper |
getLogicValidator()
Returns the validator used for validation on the logic level.
|
String |
getPropertyName()
Returns the property name of this field if one is set.
|
TransformerWrapper |
getReadTransformer()
Returns the read transformer.
|
ValidatorWrapper |
getSyntaxValidator()
Returns the validator used for validation on the syntax level.
|
Class<?> |
getType()
Returns the data type of this field.
|
TransformerWrapper |
getWriteTransformer()
Returns the write transformer.
|
void |
setComponentHandler(ComponentHandler<?> componentHandler)
Sets the component handler.
|
void |
setData(Object data)
Sets the data for this field.
|
void |
setDisplayName(String displayName)
Sets the display name.
|
void |
setLogicValidator(ValidatorWrapper formValidator)
Sets the validator used for validation on the logic level.
|
void |
setPropertyName(String n)
Sets the property name of this field.
|
void |
setReadTransformer(TransformerWrapper readTransformer)
Sets the read transformer.
|
void |
setSyntaxValidator(ValidatorWrapper fieldValidator)
Sets the validator used for validation on the syntax level.
|
void |
setType(Class<?> type)
Sets the data type for this form field.
|
void |
setWriteTransformer(TransformerWrapper writeTransformer)
Sets the write transformer.
|
ValidationResult |
validate(ValidationPhase phase)
Performs validation for the specified phase and returns the results.
|
protected ValidationResult |
validateFieldData(Object data)
Performs a form level validation of this field.
|
protected ValidationResult |
validateFieldLevel()
Performs validation on the field level.
|
protected ValidationResult |
validateFormLevel()
Performs validation on the form level.
|
public DefaultFieldHandler()
DefaultFieldHandler
.public ValidatorWrapper getSyntaxValidator()
public void setSyntaxValidator(ValidatorWrapper fieldValidator)
fieldValidator
- the field level validatorpublic ValidatorWrapper getLogicValidator()
public void setLogicValidator(ValidatorWrapper formValidator)
formValidator
- the form level validatorpublic TransformerWrapper getReadTransformer()
public void setReadTransformer(TransformerWrapper readTransformer)
readTransformer
- the read transformerpublic TransformerWrapper getWriteTransformer()
public void setWriteTransformer(TransformerWrapper writeTransformer)
writeTransformer
- the write transformerpublic ComponentHandler<?> getComponentHandler()
getComponentHandler
in interface FieldHandler
public void setComponentHandler(ComponentHandler<?> componentHandler)
componentHandler
- the component handlerpublic Class<?> getType()
ComponentHandler
's type
is returned.getType
in interface FieldHandler
public void setType(Class<?> type)
type
- the data typepublic String getPropertyName()
getPropertyName
in interface FieldHandler
public void setPropertyName(String n)
n
- the property namepublic String getDisplayName()
getDisplayName
in interface FieldHandler
public void setDisplayName(String displayName)
displayName
- the new display namepublic ValidationResult validate(ValidationPhase phase)
validate
in interface FieldHandler
phase
- the validation phasepublic Object getData()
validate(ValidationPhase)
method was called for
these phases before the form framework invokes this method).getData
in interface FieldHandler
public void setData(Object data)
setData
in interface FieldHandler
data
- the data object for this fieldprotected ValidationResult validateFieldLevel()
protected ValidationResult validateFormLevel()
getData()
method.protected Object fetchFieldData()
validate()
method. It assumes that validation on
the field level was successful.protected ValidationResult validateFieldData(Object data)
data
- the data to checkCopyright © 2016 The JGUIraffe Team. All rights reserved.