|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.millstone.base.ui.AbstractComponent | +--org.millstone.base.ui.Form
Form component provides easy way of creating and managing sets fields.
Form is a container for fields extending AbstractField
class.
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 inherited from class org.millstone.base.data.Buffered |
Buffered.SourceException |
Nested classes inherited from class org.millstone.base.data.Item |
Item.Editor, Item.PropertySetChangeEvent, Item.PropertySetChangeListener, Item.PropertySetChangeNotifier, Item.Viewer |
Nested classes inherited from class org.millstone.base.ui.Component |
Component.Event, Component.Listener |
Nested classes inherited from class org.millstone.base.terminal.Paintable |
Paintable.RepaintRequestEvent, Paintable.RepaintRequestListener |
Constructor Summary | |
Form()
Contruct a new form with default layout. |
|
Form(Layout formLayout)
Contruct a new form with given layout. |
Method Summary | |
void |
addField(java.lang.Object propertyId,
AbstractField field)
Add abstract field to form. |
boolean |
addItemProperty(java.lang.Object id,
Property property)
Add a new property to form and create corresponding field. |
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. |
AbstractField |
getField(java.lang.Object propertyId)
Get the field identified by the propertyid |
Item |
getItemDataSource()
Gets the Item serving as the data source of the viewer. |
Property |
getItemProperty(java.lang.Object id)
The property identified by the property id. |
java.util.Collection |
getItemPropertyIds()
Gets the collection of IDs of all Properties stored in the Item. |
Layout |
getLayout()
Get the layout of the form. |
java.lang.String |
getTag()
Gets the UIDL tag corresponding to the component. |
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 |
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(java.lang.Object id)
Removes the property and corresponding field from the form. |
Select |
replaceWithSelect(java.lang.Object propertyId,
java.lang.Object[] values,
java.lang.Object[] descriptions)
Set a form field to be selectable from static list of changes. |
void |
setItemDataSource(Item newDataSource)
Set the item datasource for the form. |
void |
setItemDataSource(Item newDataSource,
java.util.Collection propertyIds)
Set the item datasource for the form, but limit the form contents to specified properties of the item. |
void |
setReadThrough(boolean readThrough)
Sets the object's read-through mode to the specified status. |
void |
setWriteThrough(boolean writeThrough)
Sets the object's write-through mode to the specified status. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Form()
By default the form uses OrderedLayout
with form
-style.
public Form(Layout formLayout)
formLayout
- The layout of the form.Method Detail |
public java.lang.String getTag()
AbstractComponent
getTag
in class AbstractComponent
String
public void paintContent(PaintTarget target) throws PaintException
AbstractComponent
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.
paintContent
in class AbstractComponent
target
- target UIDL stream where the component should paint
itself to
PaintException
- if the operation failedpublic void commit() throws Buffered.SourceException
Buffered
commit
is called.
commit
in interface Buffered
Buffered.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 Buffered
Buffered.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 Buffered
true
if the value in the object has been
modified since the last data source update, false
if
not.public boolean isReadThrough()
Buffered
isReadThrough
in interface Buffered
true
if the object is in read-through mode,
false
if it's not.public boolean isWriteThrough()
Buffered
commit
being called after the modification.
isWriteThrough
in interface Buffered
true
if the object is in write-through mode,
false
if it's not.public void setReadThrough(boolean readThrough)
Buffered
setReadThrough
in interface Buffered
readThrough
- Boolean value to indicate if the object should be
in read-through mode after the call.public void setWriteThrough(boolean writeThrough)
Buffered
commit()
operation will be performed.
setWriteThrough
in interface Buffered
writeThrough
- Boolean value to indicate if the object should be
in write-through mode after the call.public boolean addItemProperty(java.lang.Object id, Property property)
addItemProperty
in interface Item
id
- ID of the new Propertyproperty
- the Property to be added and associated with
id
true
if the operation succeeded,
false
if notItem.addItemProperty(Object, Property)
public void addField(java.lang.Object propertyId, AbstractField 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
- Property id the the field.field
- New field added to the form.public Property getItemProperty(java.lang.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 Item
id
- identifier of the Property to get
null
Item.getItemProperty(Object)
public AbstractField getField(java.lang.Object propertyId)
public java.util.Collection getItemPropertyIds()
Item
getItemPropertyIds
in interface Item
public boolean removeItemProperty(java.lang.Object id)
removeItemProperty
in interface Item
id
- ID of the Property to be removed
true
if the operation succeeded
false
if notItem.removeItemProperty(Object)
public boolean removeAllProperties()
public Item getItemDataSource()
Item.Viewer
getItemDataSource
in interface Item.Viewer
public 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.Viewer
newDataSource
- The new data source ItemItem.Viewer.setItemDataSource(Item)
public void setItemDataSource(Item newDataSource, java.util.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 Select replaceWithSelect(java.lang.Object propertyId, java.lang.Object[] values, java.lang.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.
public void attach()
Component
getApplication()
and
getWindow()
functions might return null
before this method is called.
The caller of this method is Component.setParent(Component)
if the
parent is already in the application. If the parent is not in the
application, it must call the Component.attach()
for all its children
when it will be added to the application.
attach
in interface Component
attach
in class AbstractComponent
Component.attach()
public void detach()
Component
The Component.getApplication()
and Component.getWindow()
methods might return null
after this method is
called.
The caller of this method is Component.setParent(Component)
if the
parent is in the application. When the parent is detached from the application
it is its response to call Component.detach()
for all the children and
to detach itself from the terminal.
detach
in interface Component
detach
in class AbstractComponent
Component.detach()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |