public interface Form extends java.lang.Iterable<Field>, Contexed
Field
s. Once
built a Form can be used as a Map between field names and values. The methods
used to actually edit a form are specific to the implementing class.
A Form may either be used as just a collection of fields with associated validation ie as a component
of a larger composite form or may contain a set of FormAction
classes to define an action to take on form submission.
Modifier and Type | Method and Description |
---|---|
void |
addAction(java.lang.String name,
FormAction action)
add an
FormAction to this Form |
<I> Field |
addInput(java.lang.String key,
java.lang.String label,
Input<I> s)
Add and input to the next slot in the form
|
<I> Field |
addInput(java.lang.String key,
java.lang.String label,
java.lang.String help,
Input<I> s)
Add and input to the next slot in the form
|
void |
addValidator(FormValidator v)
Add a
FormValidator to perform overall sanity check on the form. |
boolean |
containsInput(java.lang.Class<? extends Input> c)
Check a form to see if it contains an input of a particular type.
|
java.lang.String |
diff(java.util.Map<java.lang.String,java.lang.Object> m)
Compare the values of this forms inputs with the contents of a Map
and generate a text summary;
|
FormResult |
doAction(java.lang.String name)
perform a named action on this form.
|
java.lang.Object |
get(java.lang.String key)
get the value associated with a Form field.
|
FormAction |
getAction(java.lang.String name)
get a
FormAction by name. |
java.util.Set<java.lang.String> |
getActionNames()
Get an
Set of the names of the installed Actions. |
java.lang.String |
getAutoFocus()
get field for auto-focus
|
java.util.Map<java.lang.String,java.lang.Object> |
getContents()
get the contents of a form as a Map
|
Field |
getField(java.lang.String key)
get a Field object
|
java.util.Iterator<java.lang.String> |
getFieldIterator()
get an iterator over the field names
|
java.lang.String |
getFormID()
get the form-ids
In HTML this is used as a prefix for the input html-ids
|
Input |
getInput(java.lang.String key)
get the Input associated with a Field
|
java.lang.Object |
getItem(java.lang.String key)
get the Item associated with a Form field.
|
Table<java.lang.String,java.lang.String> |
getTable()
get the form contents as a Table
|
default int |
getTargetStage()
get which stage of a multi-stage form is being shown/read.
|
java.util.Set<FormValidator> |
getValidators()
Get the set of
FormValidator s installed in the form. |
boolean |
hasField(java.lang.String key)
Does form contain specified field
|
default boolean |
isComplete()
returns the last value returned by
#poll(FormResult) |
default boolean |
isFixed(java.lang.String key)
Is the current value of this field fixed and connot be changed
Also returns false if the field is not defined.
|
default boolean |
poll()
Attempt to show/validate the current state of the form as part of a multi-phase
form.
|
java.lang.Object |
put(java.lang.String key,
java.lang.Object value)
set the value associated with a form field
|
void |
removeAction(java.lang.String name)
remove a
FormAction . |
void |
removeField(java.lang.String key)
remove a field from the form
|
void |
removeValidator(FormValidator v)
Remove a
FormValidator |
void |
setAutoFocus(java.lang.String field)
set field for auto-focus
|
void |
setConfirm(java.lang.String name,
java.lang.String conf) |
void |
setContents(java.util.Map<java.lang.String,java.lang.Object> m)
set the contents of a Form from a Map
|
void |
setFormID(java.lang.String id)
Set a form-id for this form.
|
default void |
setTargetStage(int stage)
set which stage of a multi-stage form is being shown/read
|
default boolean |
supportsMultiStage()
Query if multi stage forms are supported by this implementation
|
void |
update(java.util.Map<java.lang.String,java.lang.Object> m)
modify an existing Map updating the fields represented by the Form.
|
boolean |
validate()
validate a form.
|
getContext
void addAction(java.lang.String name, FormAction action)
FormAction
to this Formname
- String action-name/button-textaction
- FormActionvoid removeAction(java.lang.String name)
FormAction
.name
- FormAction getAction(java.lang.String name)
FormAction
by name.name
- <I> Field addInput(java.lang.String key, java.lang.String label, Input<I> s)
key
- key to use to refer to fieldlabel
- String to display to users
- Input to add<I> Field addInput(java.lang.String key, java.lang.String label, java.lang.String help, Input<I> s)
key
- key to use to refer to fieldlabel
- String to display to userhelp
- tooltip Strings
- Input to addboolean containsInput(java.lang.Class<? extends Input> c)
c
- Class for the Input type to be testesFormResult doAction(java.lang.String name) throws FieldException, ActionException
name
- String name of actionFieldException
ActionException
java.lang.Object get(java.lang.String key)
key
- java.lang.Object getItem(java.lang.String key)
key
- java.util.Set<java.lang.String> getActionNames()
Set
of the names of the installed Actions.void setConfirm(java.lang.String name, java.lang.String conf)
java.util.Map<java.lang.String,java.lang.Object> getContents()
Field getField(java.lang.String key)
key
- boolean hasField(java.lang.String key)
key
- default boolean isFixed(java.lang.String key)
key
- java.util.Iterator<java.lang.String> getFieldIterator()
Input getInput(java.lang.String key)
key
- Table<java.lang.String,java.lang.String> getTable()
java.lang.Object put(java.lang.String key, java.lang.Object value)
key
- value
- void removeField(java.lang.String key)
key
- void setContents(java.util.Map<java.lang.String,java.lang.Object> m)
m
- Map of valuesvoid addValidator(FormValidator v)
FormValidator
to perform overall sanity check on the form.v
- The FormValidator to set.void removeValidator(FormValidator v)
FormValidator
v
- java.util.Set<FormValidator> getValidators()
FormValidator
s installed in the form.
This is a copy of the internal set and is not modifiable, though
its members can be removed from the active set by passing them
to removeValidator(FormValidator)
void update(java.util.Map<java.lang.String,java.lang.Object> m)
m
- Map to updatejava.lang.String diff(java.util.Map<java.lang.String,java.lang.Object> m)
m
- Map to compare toboolean validate()
FormValidator
if any. No details of the
exact error are returned by this call.default boolean poll() throws TransitionException
If multi-stage submission is not supported the method will just return true.
TransitionException
default boolean supportsMultiStage()
default boolean isComplete()
#poll(FormResult)
default int getTargetStage()
default void setTargetStage(int stage)
stage
- void setFormID(java.lang.String id)
id
- java.lang.String getFormID()
void setAutoFocus(java.lang.String field)
field
- java.lang.String getAutoFocus()