|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.itmill.toolkit.terminal.Identifiable
com.itmill.toolkit.ui.AbstractComponent
com.itmill.toolkit.ui.AbstractField
com.itmill.toolkit.ui.Form
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.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class com.itmill.toolkit.ui.AbstractField |
|---|
AbstractField.ReadOnlyStatusChangeEvent |
| Nested classes/interfaces inherited from interface com.itmill.toolkit.data.Buffered |
|---|
Buffered.SourceException |
| Nested classes/interfaces inherited from interface com.itmill.toolkit.data.Item |
|---|
Item.Editor, Item.PropertySetChangeEvent, Item.PropertySetChangeListener, Item.PropertySetChangeNotifier, Item.Viewer |
| Nested classes/interfaces inherited from interface com.itmill.toolkit.ui.Field |
|---|
Field.ValueChangeEvent |
| Nested classes/interfaces inherited from interface com.itmill.toolkit.ui.Component |
|---|
Component.ErrorEvent, Component.ErrorListener, Component.Event, Component.Focusable, Component.Listener |
| Nested classes/interfaces inherited from interface com.itmill.toolkit.terminal.Paintable |
|---|
Paintable.RepaintRequestEvent, Paintable.RepaintRequestListener |
| Nested classes/interfaces inherited from interface com.itmill.toolkit.data.Property |
|---|
Property.ConversionException, Property.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer |
| Constructor Summary | |
|---|---|
Form()
Contructs a new form with default layout. |
|
Form(Layout formLayout)
Contructs a new form with given layout. |
|
Form(Layout formLayout,
FieldFactory fieldFactory)
Contructs a new form with given layout and FieldFactory. |
|
| Method Summary | |
|---|---|
void |
addField(Object propertyId,
Field field)
Adds the field to form. |
boolean |
addItemProperty(Object id,
Property property)
Adds a new property to form and create corresponding field. |
void |
addValidator(Validator validator)
Adds a new validator for this object. |
void |
attach()
Notifies the component that it is connected to an application |
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. |
void |
discard()
Discards all changes since last commit. |
void |
focus()
Focuses the first field in the form. |
Field |
getField(Object propertyId)
Gets the field identified by the propertyid. |
FieldFactory |
getFieldFactory()
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. |
String |
getTag()
Gets the UIDL tag corresponding to the component. |
Class |
getType()
Gets the field type. |
Collection |
getValidators()
Gets the Lists all validators currently registered for the object. |
Collection |
getVisibleItemProperties()
Returns the visibleProperties. |
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 |
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. |
boolean |
removeAllProperties()
Removes all properties and fields from the form. |
boolean |
removeItemProperty(Object id)
Removes the property and corresponding field from the form. |
void |
removeValidator(Validator validator)
Removes a previously registered validator from the object. |
Select |
replaceWithSelect(Object propertyId,
Object[] values,
Object[] descriptions)
Sets the form field to be selectable from static list of changes. |
void |
setFieldFactory(FieldFactory fieldFactory)
Sets the field factory of Form. |
protected void |
setFormDataSource(Object data,
Collection properties)
Updates the internal form datasource. |
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 |
setVisibleItemProperties(Collection 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 com.itmill.toolkit.ui.AbstractField |
|---|
addListener, addListener, constructField, finalize, fireReadOnlyStatusChange, fireValueChange, getErrorMessage, getFocusableId, getPropertyDataSource, getTabIndex, getValue, isInvalidCommitted, isReadOnly, isRequired, removeListener, removeListener, setInvalidCommitted, setPropertyDataSource, setRequired, setValue, toString, valueChange |
| Methods inherited from class com.itmill.toolkit.terminal.Identifiable |
|---|
getDebugId, getUIID, setDebugId, setUIID |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.itmill.toolkit.ui.Field |
|---|
getDescription, setCaption, setDescription |
| Methods inherited from interface com.itmill.toolkit.ui.Component |
|---|
addListener, childRequestedRepaint, getApplication, getCaption, getIcon, getLocale, getParent, getStyle, getWindow, isEnabled, isVisible, removeListener, setEnabled, setParent, setStyle, setVisible |
| Methods inherited from interface com.itmill.toolkit.terminal.Paintable |
|---|
addListener, paint, removeListener, requestRepaint, requestRepaintRequests |
| Methods inherited from interface com.itmill.toolkit.terminal.VariableOwner |
|---|
changeVariables, dependsOn, getDirectDependencies, isImmediate, removeDirectDependency |
| Constructor Detail |
|---|
public Form()
By default the form uses OrderedLayout with
form-style.
formLayout - the layout of the form.public Form(Layout formLayout)
formLayout - the layout of the form.
public Form(Layout formLayout,
FieldFactory fieldFactory)
formLayout - the layout of the form.fieldFactory - the FieldFactory of the form.| Method Detail |
|---|
public String getTag()
AbstractComponent
getTag in class AbstractComponentString
public void paintContent(PaintTarget target)
throws PaintException
AbstractComponentAbstractComponent.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.
paintContent in class AbstractFieldtarget - the target UIDL stream where the component should paint itself
to
PaintException - if the paint operation failed.
public void commit()
throws Buffered.SourceException
Bufferedcommit is called.
commit in interface Bufferedcommit in class AbstractFieldBuffered.SourceException - if the operation fails because of an exception is thrown by
the data source. The cause is included in the exception.
public void discard()
throws Buffered.SourceException
Buffered
discard in interface Buffereddiscard in class AbstractFieldBuffered.SourceException - if the operation fails because of an exception is thrown by
the data source. The cause is included in the exception.public boolean isModified()
Buffered
isModified in interface BufferedisModified in class AbstractFieldtrue if the value in the object has been modified
since the last data source update, false if not.public boolean isReadThrough()
BufferedThe 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.
isReadThrough in interface BufferedisReadThrough in class AbstractFieldtrue if the object is in read-through mode,
false if it's not.public boolean isWriteThrough()
Bufferedcommit being called after the modification.
isWriteThrough in interface BufferedisWriteThrough in class AbstractFieldtrue if the object is in write-through mode,
false if it's not.public void setReadThrough(boolean readThrough)
Buffered
setReadThrough in interface BufferedsetReadThrough in class AbstractFieldreadThrough - Boolean value to indicate if the object should be in
read-through mode after the call.public void setWriteThrough(boolean writeThrough)
Bufferedcommit operation
will be performed.
setWriteThrough in interface BufferedsetWriteThrough in class AbstractFieldwriteThrough - Boolean value to indicate if the object should be in
write-through mode after the call.
public boolean addItemProperty(Object id,
Property property)
addItemProperty in interface Itemid - ID of the new Propertyproperty - the Property to be added and associated with the id
true if the operation succeeded,
false if notItem.addItemProperty(Object, Property)
public void addField(Object propertyId,
Field field)
The property id must not be already used in the form.
This field is added to the form layout in the default position (the
position used by ComponentContainer.addComponent(Component) method. In the
special case that the underlying layout is a custom layout, string
representation of the property id is used instead of the default
location.
propertyId - the Property id the the field.field - the New field added to the form.public Property getItemProperty(Object 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.
getItemProperty in interface Itemid - identifier of the Property to get
nullItem.getItemProperty(Object)public Field getField(Object propertyId)
propertyId - the id of the property.public Collection getItemPropertyIds()
Item
getItemPropertyIds in interface Itempublic boolean removeItemProperty(Object id)
removeItemProperty in interface Itemid - ID of the Property to be removed
true if the operation succeededItem.removeItemProperty(Object)public boolean removeAllProperties()
true.public Item getItemDataSource()
Item.Viewer
getItemDataSource in interface Item.Viewerpublic void setItemDataSource(Item newDataSource)
Setting item datasource clears any fields, the form might contain and adds all the properties as fields to the form.
setItemDataSource in interface Item.ViewernewDataSource - The new data source ItemItem.Viewer.setItemDataSource(Item)
public void setItemDataSource(Item newDataSource,
Collection propertyIds)
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.
Item.Viewer.setItemDataSource(Item)public Layout getLayout()
By default form uses OrderedLayout with form-style.
public void setLayout(Layout newLayout)
By default form uses OrderedLayout with form-style.
newLayout - the Layout of the form.
public Select replaceWithSelect(Object propertyId,
Object[] values,
Object[] descriptions)
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.
propertyId - the id of the property.values - descriptions -
public void attach()
attach in interface Componentattach in class AbstractFieldComponent.attach()public void detach()
detach in interface Componentdetach in class AbstractComponentComponent.detach()public void addValidator(Validator validator)
addValidator in interface ValidatableaddValidator in class AbstractFieldvalidator - the new validator to be added.Validatable.addValidator(com.itmill.toolkit.data.Validator)public void removeValidator(Validator validator)
removeValidator in interface ValidatableremoveValidator in class AbstractFieldvalidator - the validator to remove.Validatable.removeValidator(com.itmill.toolkit.data.Validator)public Collection getValidators()
getValidators in interface ValidatablegetValidators in class AbstractFieldValidatable.getValidators()public boolean isValid()
isValid in interface ValidatableisValid in class AbstractFieldtrue if all registered validators claim that the
current value is valid, false otherwise.Validatable.isValid()
public void validate()
throws Validator.InvalidValueException
validate in interface Validatablevalidate in class AbstractFieldValidator.InvalidValueException - if the value is not validValidatable.validate()public boolean isInvalidAllowed()
isInvalidAllowed in interface ValidatableisInvalidAllowed in class AbstractFieldValidatable.isInvalidAllowed()
public void setInvalidAllowed(boolean invalidValueAllowed)
throws UnsupportedOperationException
setInvalidAllowed in interface ValidatablesetInvalidAllowed in class AbstractFieldUnsupportedOperationException - if the setInvalidAllowed is not supported.Validatable.setInvalidAllowed(boolean)public void setReadOnly(boolean readOnly)
setReadOnly in interface PropertysetReadOnly in interface ComponentsetReadOnly in class AbstractFieldreadOnly - the boolean value specifying if the component should be in
read-only mode after the call or not.Component.setReadOnly(boolean)public void setFieldFactory(FieldFactory fieldFactory)
FieldFactory is used to create fields for form properties.
By default the form uses BaseFieldFactory to create Field instances.
fieldFactory - the New factory used to create the fields.Field,
FieldFactorypublic FieldFactory getFieldFactory()
public Class getType()
getType in interface PropertygetType in class AbstractFieldAbstractField.getType()protected void setInternalValue(Object newValue)
setInternalValue in class AbstractFieldnewValue - the new value to be set.AbstractField.setInternalValue(java.lang.Object)
protected void setFormDataSource(Object data,
Collection properties)
data - properties - public Collection getVisibleItemProperties()
public void setVisibleItemProperties(Collection visibleProperties)
visibleProperties - the visibleProperties to set.public void focus()
focus in interface Component.Focusablefocus in class AbstractFieldComponent.Focusable.focus()public void setTabIndex(int tabIndex)
setTabIndex in interface Component.FocusablesetTabIndex in class AbstractFieldtabIndex - the tab order of this component. Negative value means
unspecified.Component.Focusable.setTabIndex(int)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||