com.vaadin.ui.
Class Form
java.lang.Object
com.vaadin.ui.AbstractComponent
com.vaadin.ui.AbstractField
com.vaadin.ui.Form
All Implemented Interfaces:
Buffered, BufferedValidatable, Item, Item.Editor, Item.Viewer, Property, Property.Editor, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer, Validatable, Action.Container, Action.Notifier, Action.ShortcutNotifier, MethodEventSource, Paintable, Sizeable, VariableOwner, Component, Component.Focusable, Field, Serializable, EventListener
- extends AbstractField
- implements Item.Editor, Buffered, Item, Validatable, Action.Notifier
public class Form
Form component provides easy way of creating and managing sets fields.
Form
is a container for fields implementing Field
interface. It provides support for any layouts and provides buffering
interface for easy connection of commit and discard buttons. All the form
fields can be customized by adding validators, setting captions and icons,
setting immediateness, etc. Also direct mechanism for replacing existing
fields with selections is given.
Form
provides customizable editor for classes implementing
Item
interface. Also the form itself implements this
interface for easier connectivity to other items. To use the form as editor
for an item, just connect the item to form with
setItemDataSource(Item)
. If only a part of the item needs to be
edited, setItemDataSource(Item,Collection)
can be used instead.
After the item has been connected to the form, the automatically created
fields can be customized and new fields can be added. If you need to connect
a class that does not implement Item
interface, most
properties of any class following bean pattern, can be accessed trough
BeanItem
.
Since:
3.0
Version:
6.8.18
Author:
Vaadin Ltd.
See Also:
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractField |
---|
AbstractField.FocusShortcut, AbstractField.ReadOnlyStatusChangeEvent |
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractComponent |
---|
AbstractComponent.ComponentErrorEvent, AbstractComponent.ComponentErrorHandler |
Nested classes/interfaces inherited from interface com.vaadin.data.Buffered |
---|
Buffered.SourceException |
Nested classes/interfaces inherited from interface com.vaadin.data.Item |
---|
Item.Editor, Item.PropertySetChangeEvent, Item.PropertySetChangeListener, Item.PropertySetChangeNotifier, Item.Viewer |
Nested classes/interfaces inherited from interface com.vaadin.ui.Field |
---|
Field.ValueChangeEvent |
Nested classes/interfaces inherited from interface com.vaadin.data.Property |
---|
Property.ConversionException, Property.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer |
Constructor Summary | |
---|---|
Form()
Constructs a new form with default layout. |
|
Form(Layout formLayout)
Constructs a new form with given Layout . |
|
Form(Layout formLayout,
FormFieldFactory fieldFactory)
Constructs a new form with given Layout and
FormFieldFactory . |
Method Summary | ||
---|---|---|
|
addAction(T action)
|
|
void |
addActionHandler(Action.Handler actionHandler)
Registers a new action handler for this container |
|
void |
addField(Object propertyId,
Field field)
Registers the field with the form and adds the field to the form layout. |
|
boolean |
addItemProperty(Object id,
Property property)
Adds a new property to form and create corresponding field. |
|
void |
addValidator(Validator validator)
Adding validators directly to form is not supported. |
|
void |
attach()
Notifies the component that it is connected to an application |
|
protected void |
attachField(Object propertyId,
Field field)
Adds the field to the form layout. |
|
protected void |
bindPropertyToField(Object propertyId,
Property property,
Field field)
Binds an item property to a field. |
|
void |
changeVariables(Object source,
Map<String,Object> variables)
Called when one or more variables handled by the implementing class are changed. |
|
void |
commit()
Updates all changes since the previous commit to the data source. |
|
void |
detach()
Notifies the component that it is detached from the application. |
|
protected void |
detachField(Field field)
Called when a form field is detached from a Form. |
|
void |
discard()
Discards all changes since last commit. |
|
void |
focus()
Focuses the first field in the form. |
|
ErrorMessage |
getErrorMessage()
The error message of a Form is the error of the first field with a non-empty error. |
|
Field |
getField(Object propertyId)
Gets the field identified by the propertyid. |
|
FieldFactory |
getFieldFactory()
Deprecated. Use getFormFieldFactory() instead. Set the
FormFieldFactory using
setFormFieldFactory(FormFieldFactory) . |
|
Layout |
getFooter()
Returns a layout that is rendered below normal form contents. |
|
FormFieldFactory |
getFormFieldFactory()
Get the field factory of the form. |
|
Item |
getItemDataSource()
Gets the Item serving as the data source of the viewer. |
|
Property |
getItemProperty(Object id)
The property identified by the property id. |
|
Collection<?> |
getItemPropertyIds()
Gets the collection of IDs of all Properties stored in the Item. |
|
Layout |
getLayout()
Gets the layout of the form. |
|
protected ActionManager |
getOwnActionManager()
Gets the ActionManager responsible for handling Action s
added to this Form.Note that Form has another ActionManager inherited from AbstractField . |
|
Class<?> |
getType()
Gets the field type. |
|
Collection<?> |
getVisibleItemProperties()
Returns the visibleProperties. |
|
protected boolean |
isEmpty()
Form is empty if all of its fields are empty. |
|
boolean |
isInvalidAllowed()
Checks the validabtable object accept invalid values. |
|
boolean |
isModified()
Tests if the value stored in the object has been modified since it was last updated from the data source. |
|
boolean |
isReadThrough()
Tests if the object is in read-through mode. |
|
boolean |
isValid()
Tests the current value of the object against all registered validators |
|
boolean |
isValidationVisibleOnCommit()
Is validation made automatically visible on commit? See setValidationVisibleOnCommit(). |
|
boolean |
isWriteThrough()
Tests if the object is in write-through mode. |
|
void |
paintContent(PaintTarget target)
Paints any needed component-specific things to the given UIDL stream. |
|
|
removeAction(T action)
|
|
void |
removeActionHandler(Action.Handler actionHandler)
Removes a previously registered action handler for the contents of this container. |
|
void |
removeAllActionHandlers()
Removes all action handlers |
|
boolean |
removeAllProperties()
Removes all properties and fields from the form. |
|
boolean |
removeItemProperty(Object id)
Removes the property and corresponding field from the form. |
|
Select |
replaceWithSelect(Object propertyId,
Object[] values,
Object[] descriptions)
Sets the form field to be selectable from static list of changes. |
|
void |
setEnabled(boolean enabled)
Enables or disables the component. |
|
void |
setFieldFactory(FieldFactory fieldFactory)
Deprecated. use setFormFieldFactory(FormFieldFactory) instead |
|
void |
setFooter(Layout newFormFooter)
Sets the layout that is rendered below normal form contens. |
|
protected void |
setFormDataSource(Object data,
Collection<?> properties)
Updates the internal form datasource. |
|
void |
setFormFieldFactory(FormFieldFactory fieldFactory)
Sets the field factory used by this Form to genarate Fields for properties. |
|
void |
setImmediate(boolean immediate)
Setting the form to be immediate also sets all the fields of the form to the same state. |
|
protected void |
setInternalValue(Object newValue)
Sets the internal value. |
|
void |
setInvalidAllowed(boolean invalidValueAllowed)
Should the validabtable object accept invalid values. |
|
void |
setItemDataSource(Item newDataSource)
Sets the item datasource for the form. |
|
void |
setItemDataSource(Item newDataSource,
Collection<?> propertyIds)
Set the item datasource for the form, but limit the form contents to specified properties of the item. |
|
void |
setLayout(Layout newLayout)
Sets the layout of the form. |
|
void |
setReadOnly(boolean readOnly)
Sets the component's to read-only mode to the specified state. |
|
void |
setReadThrough(boolean readThrough)
Sets the object's read-through mode to the specified status. |
|
void |
setTabIndex(int tabIndex)
Sets the Tabulator index of this Focusable component. |
|
void |
setValidationVisibleOnCommit(boolean makeVisible)
Controls the making validation visible implicitly on commit. |
|
void |
setVisibleItemProperties(Collection<?> visibleProperties)
Sets the visibleProperties. |
|
void |
setVisibleItemProperties(Object[] visibleProperties)
Sets the visibleProperties. |
|
void |
setWriteThrough(boolean writeThrough)
Sets the object's write-through mode to the specified status. |
|
void |
validate()
Checks the validity of the validatable. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.vaadin.data.Validatable |
---|
getValidators, removeValidator |
Methods inherited from interface com.vaadin.ui.Field |
---|
getDescription, setCaption, setDescription |
Constructor Detail |
---|
Form
public Form()
Constructs a new form with default layout.
By default the form uses FormLayout
.
Form
public Form(Layout formLayout)
- Parameters:
formLayout
- the layout of the form.
Constructs a new form with given Layout
.
Form
public Form(Layout formLayout,
FormFieldFactory fieldFactory)
- Parameters:
formLayout
- the layout of the form.fieldFactory
- the FieldFactory of the form.
Constructs a new form with given Layout
and
FormFieldFactory
.
Method Detail |
---|
paintContent
public void paintContent(PaintTarget target)
throws PaintException
- Overrides:
paintContent
in classAbstractField
- Parameters:
target
- the target UIDL stream where the component should paint itself to- Throws:
PaintException
- if the paint operation failed.
Description copied from class: AbstractComponent
Paints any needed component-specific things to the given UIDL stream. The
more general AbstractComponent.paint(PaintTarget)
method handles all general
attributes common to all components, and it calls this method to paint
any component-specific attributes to the UIDL stream.
changeVariables
public void changeVariables(Object source,
Map<String,Object> variables)
- Specified by:
changeVariables
in interfaceVariableOwner
- Overrides:
changeVariables
in classAbstractField
- Parameters:
source
- the Source of the variable change. This is the origin of the event. For example in Web Adapter this is the request.variables
- the Mapping from variable names to new variable values.
Description copied from interface: VariableOwner
Called when one or more variables handled by the implementing class are changed.
getErrorMessage
public ErrorMessage getErrorMessage()
- Overrides:
getErrorMessage
in classAbstractField
- Returns:
- ErrorMessage containing the description of the error state of the component or null, if the component contains no errors. Extending classes should override this method if they support other error message types such as validation errors or buffering errors. The returned error message contains information about all the errors.
- See Also:
AbstractComponent.getErrorMessage()
The error message of a Form is the error of the first field with a non-empty error. Empty error messages of the contained fields are skipped, because an empty error indicator would be confusing to the user, especially if there are errors that have something to display. This is also the reason why the calculation of the error message is separate from validation, because validation fails also on empty errors.
setValidationVisibleOnCommit
public void setValidationVisibleOnCommit(boolean makeVisible)
- Parameters:
makeVisible
- If true (default), validation is made visible when commit() is called. If false, the visibility is left as it is.
Controls the making validation visible implicitly on commit. Having commit() call setValidationVisible(true) implicitly is the default behaviour. You can disable the implicit setting by setting this property as false. It is useful, because you usually want to start with the form free of errors and only display them after the user clicks Ok. You can disable the implicit setting by setting this property as false.
isValidationVisibleOnCommit
public boolean isValidationVisibleOnCommit()
- Returns:
- true if validation is made automatically visible on commit.
Is validation made automatically visible on commit? See setValidationVisibleOnCommit().
commit
public void commit()
throws Buffered.SourceException,
Validator.InvalidValueException
- Specified by:
commit
in interfaceBuffered
- Overrides:
commit
in classAbstractField
- Throws:
Buffered.SourceException
- if the operation fails because of an exception is thrown by the data source. The cause is included in the exception.Validator.InvalidValueException
- if the operation fails because validation is enabled and the values do not validate
Description copied from interface: Buffered
Updates all changes since the previous commit to the data source. The
value stored in the object will always be updated into the data source
when commit
is called.
discard
public void discard()
throws Buffered.SourceException
- Specified by:
discard
in interfaceBuffered
- Overrides:
discard
in classAbstractField
- Throws:
Buffered.SourceException
- if the operation fails because of an exception is thrown by the data source. The cause is included in the exception.
Description copied from interface: Buffered
Discards all changes since last commit. The object updates its value from the data source.
isModified
public boolean isModified()
- Specified by:
isModified
in interfaceBuffered
- Overrides:
isModified
in classAbstractField
- Returns:
true
if the value in the object has been modified since the last data source update,false
if not.
Description copied from interface: Buffered
Tests if the value stored in the object has been modified since it was last updated from the data source.
isReadThrough
public boolean isReadThrough()
- Specified by:
isReadThrough
in interfaceBuffered
- Overrides:
isReadThrough
in classAbstractField
- Returns:
true
if the object is in read-through mode,false
if it's not.
Description copied from interface: Buffered
Tests if the object is in read-through mode. If the object is in read-through mode, retrieving its value will result in the value being first updated from the data source to the object.
The only exception to this rule is that when the object is not in write-through mode and it's buffer contains a modified value, the value retrieved from the object will be the locally modified value in the buffer which may differ from the value in the data source.
isWriteThrough
public boolean isWriteThrough()
- Specified by:
isWriteThrough
in interfaceBuffered
- Overrides:
isWriteThrough
in classAbstractField
- Returns:
true
if the object is in write-through mode,false
if it's not.
Description copied from interface: Buffered
Tests if the object is in write-through mode. If the object is in
write-through mode, all modifications to it will result in
commit
being called after the modification.
setReadThrough
public void setReadThrough(boolean readThrough)
- Specified by:
setReadThrough
in interfaceBuffered
- Overrides:
setReadThrough
in classAbstractField
- Parameters:
readThrough
- Boolean value to indicate if the object should be in read-through mode after the call.
Description copied from interface: Buffered
Sets the object's read-through mode to the specified status. When switching read-through mode on, the object's value is updated from the data source.
setWriteThrough
public void setWriteThrough(boolean writeThrough)
throws Buffered.SourceException,
Validator.InvalidValueException
- Specified by:
setWriteThrough
in interfaceBuffered
- Overrides:
setWriteThrough
in classAbstractField
- Parameters:
writeThrough
- Boolean value to indicate if the object should be in write-through mode after the call.- Throws:
Buffered.SourceException
- If the operation fails because of an exception is thrown by the data source.Validator.InvalidValueException
- If the implicit commit operation fails because of a validation error.
Description copied from interface: Buffered
Sets the object's write-through mode to the specified status. When
switching the write-through mode on, the commit
operation
will be performed.
addItemProperty
public boolean addItemProperty(Object id,
Property property)
- Specified by:
addItemProperty
in interfaceItem
- Parameters:
id
- ID of the new Propertyproperty
- the Property to be added and associated with the id- Returns:
true
if the operation succeeded,false
if not- See Also:
Item.addItemProperty(Object, Property)
Adds a new property to form and create corresponding field.
addField
public void addField(Object propertyId,
Field field)
- Parameters:
propertyId
- the Property id the the field.field
- the field which should be added to the form.
Registers the field with the form and adds the field to the form layout.
The property id must not be already used in the form.
This field is added to the layout using the
attachField(Object, Field)
method.
attachField
protected void attachField(Object propertyId,
Field field)
- Parameters:
propertyId
-field
-
Adds the field to the form layout.
The field is added to the form layout in the default position (the
position used by ComponentContainer.addComponent(Component)
. If the
underlying layout is a CustomLayout
the field is added to the
CustomLayout location given by the string representation of the property
id using CustomLayout.addComponent(Component, String)
.
Override this method to control how the fields are added to the layout.
getItemProperty
public Property getItemProperty(Object id)
- Specified by:
getItemProperty
in interfaceItem
- Parameters:
id
- identifier of the Property to get- Returns:
- the Property with the given ID or
null
- See Also:
Item.getItemProperty(Object)
The property identified by the property id.
The property data source of the field specified with property id is returned. If there is a (with specified property id) having no data source, the field is returned instead of the data source.
getField
public Field getField(Object propertyId)
- Parameters:
propertyId
- the id of the property.
Gets the field identified by the propertyid.
getItemPropertyIds
public Collection<?> getItemPropertyIds()
- Specified by:
getItemPropertyIds
in interfaceItem
- Returns:
- unmodifiable collection containing IDs of the Properties stored the Item
Description copied from interface: Item
Gets the collection of IDs of all Properties stored in the Item.
removeItemProperty
public boolean removeItemProperty(Object id)
- Specified by:
removeItemProperty
in interfaceItem
- Parameters:
id
- ID of the Property to be removed- Returns:
true
if the operation succeeded- See Also:
Item.removeItemProperty(Object)
Removes the property and corresponding field from the form.
detachField
protected void detachField(Field field)
- Parameters:
field
- the field to be detached from the forms layout.
Called when a form field is detached from a Form. Typically when a new
Item is assigned to Form via setItemDataSource(Item)
.
Override this method to control how the fields are removed from the layout.
removeAllProperties
public boolean removeAllProperties()
- Returns:
- the Success of the operation. Removal of all fields succeeded if
(and only if) the return value is
true
.
Removes all properties and fields from the form.
getItemDataSource
public Item getItemDataSource()
- Specified by:
getItemDataSource
in interfaceItem.Viewer
- Returns:
- data source Item
Description copied from interface: Item.Viewer
Gets the Item serving as the data source of the viewer.
setItemDataSource
public void setItemDataSource(Item newDataSource)
- Specified by:
setItemDataSource
in interfaceItem.Viewer
- Parameters:
newDataSource
- The new data source Item- See Also:
Item.Viewer.setItemDataSource(Item)
Sets the item datasource for the form.
Setting item datasource clears any fields, the form might contain and adds all the properties as fields to the form.
setItemDataSource
public void setItemDataSource(Item newDataSource,
Collection<?> propertyIds)
- See Also:
Item.Viewer.setItemDataSource(Item)
Set the item datasource for the form, but limit the form contents to specified properties of the item.
Setting item datasource clears any fields, the form might contain and adds the specified the properties as fields to the form, in the specified order.
bindPropertyToField
protected void bindPropertyToField(Object propertyId,
Property property,
Field field)
- Parameters:
propertyId
-property
-field
-- Since:
- 6.7.3
Binds an item property to a field. The default behavior is to bind property straight to Field. If Property.Viewer type property (e.g. PropertyFormatter) is already set for field, the property is bound to that Property.Viewer.
getLayout
public Layout getLayout()
- Returns:
- the Layout of the form.
Gets the layout of the form.
By default form uses OrderedLayout
with form
-style.
setLayout
public void setLayout(Layout newLayout)
- Parameters:
newLayout
- the Layout of the form.
Sets the layout of the form.
By default form uses OrderedLayout
with form
-style.
replaceWithSelect
public Select replaceWithSelect(Object propertyId,
Object[] values,
Object[] descriptions)
- Parameters:
propertyId
- the id of the property.values
-descriptions
-- Returns:
- the select property generated
Sets the form field to be selectable from static list of changes.
The list values and descriptions are given as array. The value-array must contain the current value of the field and the lengths of the arrays must match. Null values are not supported.
attach
public void attach()
- Specified by:
attach
in interfaceComponent
- Overrides:
attach
in classAbstractField
- See Also:
Component.attach()
Notifies the component that it is connected to an application
detach
public void detach()
- Specified by:
detach
in interfaceComponent
- Overrides:
detach
in classAbstractField
- See Also:
Component.detach()
Notifies the component that it is detached from the application.
isValid
public boolean isValid()
- Specified by:
isValid
in interfaceValidatable
- Overrides:
isValid
in classAbstractField
- Returns:
true
if all registered validators claim that the current value is valid or if the field is empty and not required,false
otherwise.- See Also:
Validatable.isValid()
Tests the current value of the object against all registered validators
validate
public void validate()
throws Validator.InvalidValueException
- Specified by:
validate
in interfaceValidatable
- Overrides:
validate
in classAbstractField
- Throws:
Validator.InvalidValueException
- if the value is not valid- See Also:
Validatable.validate()
Checks the validity of the validatable.
isInvalidAllowed
public boolean isInvalidAllowed()
- Specified by:
isInvalidAllowed
in interfaceValidatable
- Overrides:
isInvalidAllowed
in classAbstractField
- Returns:
- true iff the invalid values are allowed.
- See Also:
Validatable.isInvalidAllowed()
Checks the validabtable object accept invalid values.
setInvalidAllowed
public void setInvalidAllowed(boolean invalidValueAllowed)
throws UnsupportedOperationException
- Specified by:
setInvalidAllowed
in interfaceValidatable
- Overrides:
setInvalidAllowed
in classAbstractField
- Throws:
UnsupportedOperationException
- if the setInvalidAllowed is not supported.- See Also:
Validatable.setInvalidAllowed(boolean)
Should the validabtable object accept invalid values.
setReadOnly
public void setReadOnly(boolean readOnly)
- Specified by:
setReadOnly
in interfaceProperty
- Specified by:
setReadOnly
in interfaceComponent
- Overrides:
setReadOnly
in classAbstractField
- Parameters:
readOnly
- a boolean value specifying whether the component is put read-only mode or not- See Also:
Component.setReadOnly(boolean)
Sets the component's to read-only mode to the specified state.
setFieldFactory
@Deprecated
public void setFieldFactory(FieldFactory fieldFactory)
- Parameters:
fieldFactory
- the New factory used to create the fields.- See Also:
Field
,FormFieldFactory
Deprecated. use setFormFieldFactory(FormFieldFactory)
instead
Sets the field factory of Form.
FieldFactory
is used to create fields for form properties.
By default the form uses BaseFieldFactory to create Field instances.
setFormFieldFactory
public void setFormFieldFactory(FormFieldFactory fieldFactory)
- Parameters:
fieldFactory
- the new factory used to create the fields.- See Also:
Field
,FormFieldFactory
Sets the field factory used by this Form to genarate Fields for
properties.
FormFieldFactory
is used to create fields for form properties.
DefaultFieldFactory
is used by default.
getFormFieldFactory
public FormFieldFactory getFormFieldFactory()
- Returns:
- the FormFieldFactory Factory used to create the fields.
Get the field factory of the form.
getFieldFactory
@Deprecated
public FieldFactory getFieldFactory()
- Returns:
- the FieldFactory Factory used to create the fields.
Deprecated. Use getFormFieldFactory()
instead. Set the
FormFieldFactory using
setFormFieldFactory(FormFieldFactory)
.
Get the field factory of the form.
getType
public Class<?> getType()
- Specified by:
getType
in interfaceProperty
- Specified by:
getType
in classAbstractField
- Returns:
- type of the Property
- See Also:
AbstractField.getType()
Gets the field type.
setInternalValue
protected void setInternalValue(Object newValue)
- Overrides:
setInternalValue
in classAbstractField
- Parameters:
newValue
- the new value to be set.- See Also:
AbstractField.setInternalValue(java.lang.Object)
Sets the internal value. This is relevant when the Form is used as Field.
setFormDataSource
protected void setFormDataSource(Object data,
Collection<?> properties)
- Parameters:
data
-properties
-
Updates the internal form datasource. Method setFormDataSource.
getVisibleItemProperties
public Collection<?> getVisibleItemProperties()
- Returns:
- the Collection of visible Item properites.
Returns the visibleProperties.
setVisibleItemProperties
public void setVisibleItemProperties(Collection<?> visibleProperties)
- Parameters:
visibleProperties
- the visibleProperties to set.
Sets the visibleProperties.
setVisibleItemProperties
public void setVisibleItemProperties(Object[] visibleProperties)
- Parameters:
visibleProperties
- the visibleProperties to set.
Sets the visibleProperties.
focus
public void focus()
- Specified by:
focus
in interfaceComponent.Focusable
- Overrides:
focus
in classAbstractField
- See Also:
Component.Focusable.focus()
Focuses the first field in the form.
setTabIndex
public void setTabIndex(int tabIndex)
- Specified by:
setTabIndex
in interfaceComponent.Focusable
- Overrides:
setTabIndex
in classAbstractField
- Parameters:
tabIndex
- the tab order of this component. Indexes usually start from 1. Zero means that default tab order should be used. A negative value means that the field should not be included in the tabbing sequence.- See Also:
Component.Focusable.setTabIndex(int)
Sets the Tabulator index of this Focusable component.
setImmediate
public void setImmediate(boolean immediate)
- Overrides:
setImmediate
in classAbstractComponent
- Parameters:
immediate
- the boolean value specifying if the component should be in the immediate mode after the call.- See Also:
VariableOwner.isImmediate()
Setting the form to be immediate also sets all the fields of the form to the same state.
isEmpty
protected boolean isEmpty()
- Overrides:
isEmpty
in classAbstractField
Form is empty if all of its fields are empty.
addValidator
public void addValidator(Validator validator)
- Specified by:
addValidator
in interfaceValidatable
- Overrides:
addValidator
in classAbstractField
- Parameters:
validator
- the new validator to be added.
Adding validators directly to form is not supported. Add the validators to form fields instead.
getFooter
public Layout getFooter()
- Returns:
- layout rendered below normal form contents.
Returns a layout that is rendered below normal form contents. This area can be used for example to include buttons related to form contents.
setFooter
public void setFooter(Layout newFormFooter)
- Parameters:
newFormFooter
- the new Layout
Sets the layout that is rendered below normal form contens.
setEnabled
public void setEnabled(boolean enabled)
- Specified by:
setEnabled
in interfaceComponent
- Overrides:
setEnabled
in classAbstractComponent
- Parameters:
enabled
- a boolean value specifying if the component should be enabled or not
Description copied from interface: Component
Enables or disables the component. The user can not interact disabled components, which are shown with a style that indicates the status, usually shaded in light gray color. Components are enabled by default. Children of a disabled component are automatically disabled; if a child component is explicitly set as disabled, changes in the disabled status of its parents do not change its status.
Button enabled = new Button("Enabled");
enabled.setEnabled(true); // The default
layout.addComponent(enabled);
Button disabled = new Button("Disabled");
disabled.setEnabled(false);
layout.addComponent(disabled);
This method will trigger a
RepaintRequestEvent
for the component and, if it is a
ComponentContainer
, for all its children recursively.
getOwnActionManager
protected ActionManager getOwnActionManager()
- Returns:
Gets the ActionManager
responsible for handling Action
s
added to this Form.
Note that Form has another ActionManager inherited from
AbstractField
. The ownActionManager handles Actions attached to
this Form specifically, while the ActionManager in AbstractField
delegates to the containing Window (i.e global Actions).
addActionHandler
public void addActionHandler(Action.Handler actionHandler)
- Specified by:
addActionHandler
in interfaceAction.Container
- Parameters:
actionHandler
- the new handler to be added.
Description copied from interface: Action.Container
Registers a new action handler for this container
removeActionHandler
public void removeActionHandler(Action.Handler actionHandler)
- Specified by:
removeActionHandler
in interfaceAction.Container
- Parameters:
actionHandler
- the handler to be removed.
Description copied from interface: Action.Container
Removes a previously registered action handler for the contents of this container.
removeAllActionHandlers
public void removeAllActionHandlers()
Removes all action handlers
addAction
public <T extends Action & Action.Listener> void addAction(T action)
- Specified by:
addAction
in interfaceAction.Notifier
removeAction
public <T extends Action & Action.Listener> void removeAction(T action)
- Specified by:
removeAction
in interfaceAction.Notifier