public interface FormItem extends FormBaseComponentIdProvider
FormDecorator
instance in the velocity.
The java code to create the above yes-no-switch looks as follows. Please note the anonymous class creation style, with a initializer block. This helps grouping the
code:
The form item goes to a velocity page under defined name, e.g. dateSwitch, and the corresponding logical panels are accessed with the following convention:
org.olat.presentation.framework.components.form.flexible.FormDecorator
which can be accessed for example as $f.hasError("dateSwitch").
The FormItem
is aggregated within FormItemContainer
and both together form the composite pattern.
They play together with the Component
and Container
Initial Date: 24.11.2006
限定符和类型 | 字段和说明 |
---|---|
static java.lang.String |
ERRORC |
static java.lang.String |
EXAMPLEC |
static java.lang.String |
LABELC |
DISPPREFIX
限定符和类型 | 方法和说明 |
---|---|
void |
addActionListener(Controller listener,
int events) |
void |
clearError()
error is resolved, e.g. hasError() should return false and the error component gets invisible (and resetted)
|
void |
doDispatchFormRequest(UserRequest ureq)
called if this component is dispatched, e.g. was clicked (double clicked, ...)
|
void |
evalFormRequest(UserRequest ureq)
called if just the form values must be remembered for the next render process.
|
int |
getAction() |
java.util.List<java.lang.String> |
getActionListenersFor(int event) |
Component |
getComponent()
The elements panel to be rendered by the GUI Framework.
|
Component |
getErrorC()
a complex "error" message, or a helper wizard to fix the error may be
This method is used by a form infrastructure provider.
|
java.lang.String |
getErrorText()
This method is used by a form infrastructure provider.
|
Component |
getExampleC()
translated example text, wrapped in component
This method is used by a form infrastructure provider.
|
java.lang.String |
getExampleText()
This method is used by a form infrastructure provider.
|
Component |
getLabelC()
label panel of the form item,
null if no label provided/rendered
This method is used by a form infrastructure provider. |
java.lang.String |
getLabelText()
label panel of the form item,
null if no label provided/rendered
This method is used by a form infrastructure provider. |
java.lang.String |
getName()
The form item's name within an manageing form container.
|
Form |
getRootForm()
a form item always has a root container where it belongs to.
|
Translator |
getTranslator() |
java.lang.Object |
getUserObject() |
boolean |
hasError() |
boolean |
hasExample() |
boolean |
hasFocus()
true if this element tries to get focus.
|
boolean |
hasLabel() |
boolean |
isEnabled()
true if item is marked as editable.
|
boolean |
isMandatory()
true if the form item should contain a (valid) value.
|
boolean |
isVisible()
true if form item was marked visible.
|
void |
reset()
reset the data in the field to a initial/predefined value.
|
void |
setEnabled(boolean isEnabled)
item is enabled/disabled, e.g. editable/read only in contrast to setVisible this does NOT DISABLE label, example, error!
|
void |
setErrorComponent(FormItem errorFormItem,
FormLayouter container)
a complex "error" message, or a helper wizard to fix the error.
|
void |
setErrorKey(java.lang.String errorKey,
java.lang.String... params)
Sets the i18n key for this form item's error message and displays the error message if showErro(true) is set.
|
void |
setExampleKey(java.lang.String exampleKey,
java.lang.String[] params)
key for example with params to fill
|
void |
setFocus(boolean hasFocus)
true if the element should (try to) get focus, false is default
|
void |
setLabel(java.lang.String labelkey,
java.lang.String[] params)
Key to be translated with the form translator and placed in the label panel.
|
FormItem |
setLabelComponent(FormItem labelComponent,
FormItemContainer formLayout)
see setErrorComponent for comments
|
void |
setMandatory(boolean isMandatory)
Shows a mandatory icon next to this form item.
|
void |
setRootForm(Form rootForm) |
void |
setTranslator(Translator translator) |
void |
setUserObject(java.lang.Object userObject) |
void |
setVisible(boolean isVisible)
item, label, example, error get not visible
|
void |
showError(boolean show) |
void |
showExample(boolean show) |
void |
showLabel(boolean show) |
void |
validate(java.util.List<ValidationStatus> validationResults)
validate the data in the field, create error messages or update any component.
|
getFormDispatchId
static final java.lang.String ERRORC
static final java.lang.String EXAMPLEC
static final java.lang.String LABELC
void evalFormRequest(UserRequest ureq)
This method must be implemented by a specialised form item provider.
ureq
- dispatchIDs
- nextPos
- void validate(java.util.List<ValidationStatus> validationResults)
This method must be implemented by a specialised form item provider.
void reset()
void setFocus(boolean hasFocus)
hasFocus
- boolean hasFocus()
void doDispatchFormRequest(UserRequest ureq)
Please note, that the caller is not the GUI Framework but the form items manageing class. A default and exemplary implemention is Form
.
This method must be implemented by a specialised form item provider.
ureq
- dispatchIDs
- nextPos
- java.lang.String getName()
FormItemImpl
uses the name to make the element available in the velocity container.
This method is used by a form infrastructure provider.
Component getComponent()
Form getRootForm()
This method must be implemented by a specialised form item provider.
Component getLabelC()
null
if no label provided/rendered
This method is used by a form infrastructure provider.
java.lang.String getLabelText()
null
if no label provided/rendered
This method is used by a form infrastructure provider.
void setLabel(java.lang.String labelkey, java.lang.String[] params)
labelkey
- i18n keyparams
- i18n key parametersFormItem setLabelComponent(FormItem labelComponent, FormItemContainer formLayout)
labelComponent
- layout
- boolean isMandatory()
void setMandatory(boolean isMandatory)
isMandatory
- Whether this form item should have a mandatory icon.void setErrorKey(java.lang.String errorKey, java.lang.String... params)
errorKey
- i18n key for the error message.params
- Additional error message contents.void setErrorComponent(FormItem errorFormItem, FormLayouter container)
FormLink
is used here to start a workflow in a modal dialog.errorFormItem
- container
- the container containing the form item which has the errorComponent getErrorC()
This method is used by a form infrastructure provider. null
java.lang.String getErrorText()
This method is used by a form infrastructure provider.
Component getExampleC()
This method is used by a form infrastructure provider.
java.lang.String getExampleText()
This method is used by a form infrastructure provider.
void setExampleKey(java.lang.String exampleKey, java.lang.String[] params)
exampleKey
- , null to clear exampleparams
- , may be nullvoid setTranslator(Translator translator)
translator
- Translator getTranslator()
void setVisible(boolean isVisible)
isVisible
- boolean isVisible()
void setEnabled(boolean isEnabled)
isEnabled
- boolean isEnabled()
boolean hasError()
boolean hasLabel()
boolean hasExample()
void setRootForm(Form rootForm)
rootForm
- void showLabel(boolean show)
show
- void showError(boolean show)
show
- void clearError()
void showExample(boolean show)
show
- void addActionListener(Controller listener, int events)
listener
- events
- java.util.List<java.lang.String> getActionListenersFor(int event)
event
- int getAction()
void setUserObject(java.lang.Object userObject)
userObject
- java.lang.Object getUserObject()