Abstract field component for implementing buffered property editors. The
field may hold an internal value, or it may be connected to any data source
that implements the
com.itmill.toolkit.data.Property
interface.
AbstractField
implements that interface itself, too, so
accessing the Property value represented by it is straightforward.
AbstractField also provides the
com.itmill.toolkit.data.Buffered
interface for buffering the data source value. By default the Field is in
write through-mode and
com.itmill.toolkit.ui.AbstractField
should be called to
enable buffering.
The class also supports
validators
to make sure the value contained in the field is valid.
3.0
Inheritance Path. java.lang.Object-> com.itmill.toolkit.ui.AbstractComponent -> com.itmill.toolkit.ui.AbstractField
Parameters
listener
the new Listener to be registered
Registers a new read-only status change listener for this Property.
Parameters
validator
the new validator to be added
Adds a new validator for the field's value. All validators added to a field are checked each time the its value changes.
attach()
Parameters
propertyType
Type of the property, that needs to be edited.
Create abstract field by the type of the property.
This returns most suitable field type for editing property of given type
getErrorMessage()
Error messages shown by the fields are composites of the error message thrown by the superclasses (that is the component error message), validation errors and buffered source errors.
getFocusableId()
Parameters
The current data source as a Property, or
null
if
none defined.
Gets the current data source of the field, if any.
Parameters
Tab index of this field. Negative value means unspecified.
Get the tab index of this field. The tab index property is used to specify the natural tab ordering of fields.
Parameters
Unmodifiable collection that holds all validators for the field.
Gets the validators of the field.
Parameters
the current value of the field
Gets the current value of the field. This is the visible, modified and possible invalid value the user have entered to the field. In the read-through mode, the abstract buffer is also updated and validation is performed.
Parameters
true iff the invalid values are allowed.
isInvalidAllowed()
Fields allow invalid values by default. In most cases this is wanted, because the field otherwise visually forget the user input immediately.
Parameters
true if the
Is this field required. Required fields must filled by the user.
Parameters
true
if all registered validators claim that the
current value is valid,
false
otherwise
Tests the current value against all registered validators.
Parameters
listener
listener to be removed
Remove a previously registered read-only status change listener.
Parameters
validator
the validator to remove
Removes a validator from the field.
setInvalidAllowed(boolean)
Fields allow invalid values by default. In most cases this is wanted, because the field otherwise visually forget the user input immediately. In common setting where the user wants to assure the correctness of the datasource, but allow temporarily invalid contents in the field, the user should add the validators to datasource, that should not allow invalid values. The validators are automatically copied to the field when the datasource is set.
Parameters
newDataSource
the new data source Property
Sets the specified Property as the data source for the field. All uncommitted changes to the field are discarded and the value is refreshed from the new data source.
If the datasource has any validators, the same validators are added to the field. Because the default behavior of the field is to allow invalid values, but not to allow committing them, this only adds visual error messages to fields and do not allow committing them as long as the value is invalid. After the value is valid, the error message is not shown and the commit can be done normally.
setReadOnly(boolean)
Change the readonly state and throw read-only status change events.
Parameters
required
Is the field required
Set the field required. Required fields must filled by the user.
Parameters
tabIndex
The tab order of this component. Negative value means unspecified.
Get the tab index of this field. The tab index property is used to specify the natural tab ordering of fields.
Parameters
String
representation of the value stored in the
Property
Returns the value of the Property in human readable textual format.