Package net.sf.jguiraffe.gui.forms
Interface FieldHandler
-
- All Known Implementing Classes:
DefaultFieldHandler
public interface FieldHandler
Definition of an interface for accessing fields of a form.
A form consists of an arbitrary number of fields, i.e. interaction elements where the user can enter data. Such a field must be able to interact with the GUI widget used for data entering. In addition it supports validation of the entered data and conversion into a target data type.
- Version:
- $Id: FieldHandler.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ComponentHandler<?>
getComponentHandler()
Returns theComponentHandler
used by thisFieldHandler
.Object
getData()
Returns the data of this field.String
getDisplayName()
Returns the display name of this field.String
getPropertyName()
Returns the name of the corresponding property in the form bean.Class<?>
getType()
Returns the data type for this field.void
setData(Object data)
Sets the data of this field.ValidationResult
validate(ValidationPhase phase)
Validates this field either at the field or the form level.
-
-
-
Method Detail
-
getComponentHandler
ComponentHandler<?> getComponentHandler()
Returns theComponentHandler
used by thisFieldHandler
. With this handler, the underlying GUI component can be controlled.- Returns:
- the associated
ComponentHandler
-
getData
Object getData()
Returns the data of this field. This is not necessary the same data object as returned by theComponentHandler
. Instead it can be the result of a conversion process to transform the data into a certain target data type. For this conversion to succeed it must be ensured that this method is only envoked after validation at the field level has been successfull. The object returned here should be of the same type as returned by
.getType()
- Returns:
- the data of this field
-
setData
void setData(Object data)
Sets the data of this field. An implementation must perform suitable conversions and then write the data into the associated GUI component. This is the opposite of
.getData()
- Parameters:
data
- the data to set
-
validate
ValidationResult validate(ValidationPhase phase)
Validates this field either at the field or the form level. The returnedValidationResult
object contains information if the field's content is valid or which errors have been found.- Parameters:
phase
- determines the validation phase- Returns:
- an object with the validation results
-
getType
Class<?> getType()
Returns the data type for this field. Valid user input will be converted into this data type.- Returns:
- the data type of this field
-
getPropertyName
String getPropertyName()
Returns the name of the corresponding property in the form bean. This method can return null, which means that the bean property has the same name as this field. But by specifying a different name it is possible to map to more complex bean properties, e.g. mapped or indexed ones.- Returns:
- the name of the corresponding bean property
-
getDisplayName
String getDisplayName()
Returns the display name of this field. This should be a plain name in the language of the current user. The method can return null if no display name has been set. In this case the form will use the field name also as display name.- Returns:
- a display name for this field
-
-