public class FieldHandler extends Hashtable
You use this by creating the FieldHandler and setting the Class of the Object to be edited. Then associate fields with Controls using the add() method. Then call addFieldHandler() on a Form to activate the FieldHandler. The Controls that you add to the FieldHandler must be child Controls of the Form.
Modifier and Type | Field and Description |
---|---|
Object |
data
This holds the Object itself that is being edited.
|
Class |
objectClass
This is the type of the Object being edited.
|
serialVersionUID
Constructor and Description |
---|
FieldHandler()
Create an empty FieldHandler.
|
FieldHandler(Object dataObject)
Create a FieldHandler to handle a particular data Object.
|
Modifier and Type | Method and Description |
---|---|
Control |
add(String fieldName,
Control fieldControl)
Add a field.
|
Control |
add(String fieldName,
Control fieldControl,
int transferOptionsToSet,
int transferOptionsToClear)
Add a field specifying transferOptions to set and/or clear.
|
protected void |
fieldAction(Control fieldControl,
Form f)
Override this to handle field action events (e.g. when a Button is pressed).
|
protected void |
fieldChanged(Control fieldControl,
Form f)
Override this to handle when a field value changes.
|
protected void |
fieldEvent(Control fieldControl,
Form f,
Event ev)
This is called for any ControlEvent generated by the Control other
than ControlEvent.PRESSED (handled by fieldAction()) or a DataChangeEvent
(handled by fieldChanged()).
|
void |
fromControls()
Transfer data to all the fields from the Controls.
|
void |
fromControls(String fieldNames)
Transfer data from the he Control elements to the specified Object fields.
|
Control |
getControlFor(String fieldName)
Find the Control that was assigned to the specified field.
|
FieldTransfer |
getFieldTransferFor(Control c)
Get the FieldTransfer associated with a Control.
|
FieldTransfer |
getFieldTransferFor(String fieldName)
Get the FieldTransfer Object responsible for data transfer between
the Control and the Object field.
|
void |
gotEvent(Event ev,
Form f)
The Form with this FieldHandler passes events to the handler through this method.
|
void |
setObject(Object obj)
Set the data Object and transfer all the fields to Controls.
|
void |
toControls()
Transfer data from all the fields to the Controls.
|
void |
toControls(String fieldNames)
Transfer data from the specified Object fields to the Control elements
on screen.
|
clear, clone, contains, containsKey, containsValue, elements, entrySet, get, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values
public Class objectClass
public Object data
public FieldHandler(Object dataObject)
dataObject
- this becomes the data Objectpublic FieldHandler()
public Control getControlFor(String fieldName)
fieldName
- the field name.public FieldTransfer getFieldTransferFor(String fieldName)
fieldName
- the Field name.public FieldTransfer getFieldTransferFor(Control c)
c
- the Control.public void toControls(String fieldNames)
fieldNames
- a comma separated list of field names.public void fromControls(String fieldNames)
fieldNames
- a comma separated list of field names.public void toControls()
public void fromControls()
public void setObject(Object obj)
obj
- the new Data object. This can be null but must be compatible
with the objectClass type.public Control add(String fieldName, Control fieldControl, int transferOptionsToSet, int transferOptionsToClear)
fieldName
- the name of the field.fieldControl
- the Control being used to display/edit the field.FieldTransfer
- options to set.FieldTransfer
- options to clear.public Control add(String fieldName, Control fieldControl)
fieldName
- the name of the field.fieldControl
- the Control being used to display/edit the field.protected void fieldAction(Control fieldControl, Form f)
fieldControl
- the Control generated the action. To determine
the name of the field call getFieldTransferFor(fieldControl) and
then use the fieldName field of the returned FieldTransfer.f
- the Form the FieldHandler was associated with.protected void fieldChanged(Control fieldControl, Form f)
fieldControl
- the Control generated the action. To determine
the name of the field call getFieldTransferFor(fieldControl) and
then use the fieldName field of the returned FieldTransfer.f
- the Form the FieldHandler was associated with.protected void fieldEvent(Control fieldControl, Form f, Event ev)
fieldControl
- the Control generated the action. To determine
the name of the field call getFieldTransferFor(fieldControl) and
then use the fieldName field of the returned FieldTransfer.f
- the Form the FieldHandler was associated with.ev
- the ControlEvent generated by the Control.