org.olat.core.gui.components.form.flexible.impl
Class FormItemImpl

java.lang.Object
  extended by org.olat.core.gui.components.form.flexible.impl.FormItemImpl
All Implemented Interfaces:
InlineElement, FormBaseComponentIdProvider, FormItem
Direct Known Subclasses:
AbstractTextElement, FileElementImpl, FlexiTableElementImpl, FormCancel, FormLayoutContainer, FormLinkImpl, FormReset, FormSubmit, MultipleSelectionElementImpl, SingleSelectionImpl, SpacerElementImpl, StaticTextElementImpl

public abstract class FormItemImpl
extends java.lang.Object
implements FormItem, InlineElement

Description:

Initial Date: 22.11.2006

Author:
patrickb

Field Summary
 
Fields inherited from interface org.olat.core.gui.components.form.flexible.FormItem
ERRORC, EXAMPLEC, LABELC
 
Fields inherited from interface org.olat.core.gui.components.form.flexible.FormBaseComponentIdProvider
DISPPREFIX
 
Constructor Summary
FormItemImpl(java.lang.String name)
           
FormItemImpl(java.lang.String name, boolean asInlineEditingElement)
           
 
Method Summary
 void addActionListener(Controller listener, int action)
           
 void clearError()
          error is resolved, e.g.
 void doDispatchFormRequest(UserRequest ureq)
          gets called if the implementing component was clicked.
abstract  void evalFormRequest(UserRequest ureq)
          gets called if the implementing component is part of a form which gets partly submitted -> extract data for you and store it temporarly for redisplay without a validation
 int getAction()
           
 java.util.List getActionListenersFor(int event)
           
 Component getComponent()
          The elements panel to be rendered by the GUI Framework.
 java.lang.String getEmptyDisplayText()
           
 Component getErrorC()
          a complex "error" message, or a helper wizard to fix the error may be
 java.lang.String getErrorText()
           This method is used by a form infrastructure provider.
 Component getExampleC()
          translated example text, wrapped in component
 java.lang.String getExampleText()
           This method is used by a form infrastructure provider.
 java.lang.String getFormDispatchId()
          A String containing a unique ID per form element component on the screen.
 Component getLabelC()
          label panel of the form item, null if no label provided/rendered
 java.lang.String getLabelText()
          label panel of the form item, null if no label provided/rendered
 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 isInlineEditingOn()
           
 boolean isMandatory()
          true if the form item should contain a (valid) value.
 boolean isVisible()
          true if form item was marked visible.
abstract  void reset()
          reset the data in the field to a initial/predefined value.
 FormItem setEmptyDisplayText(java.lang.String i18nKey4Text)
           
 void setEnabled(boolean isEnabled)
          item is enabled/disabled, e.g.
 void setErrorComponent(FormItem errorFormItem, FormLayouter container)
          a complex "error" message, or a helper wizard to fix the error.
It must be a form item itself, that starting the fixing workflow let the surrounding form evaluate (intermediate save values).
Typically a FormLink is used here to start a workflow in a modal dialog.
Use showError(true) for the visibility of 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 label, java.lang.String[] params)
          Key to be translated with the form translator and placed in the label panel.
 FormItem setLabelComponent(FormItem labelComponent, FormItemContainer container)
          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)
           
 java.lang.String toString()
           
abstract  void validate(java.util.List validationResults)
          validate the data in the field, create error messages or update any component.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FormItemImpl

public FormItemImpl(java.lang.String name)
Parameters:
name -

FormItemImpl

public FormItemImpl(java.lang.String name,
                    boolean asInlineEditingElement)
Method Detail

getName

public java.lang.String getName()
Description copied from interface: FormItem
The form item's name within an manageing form container. This has nothing to do with a name displayed on the screen to the user.
The default implementation FormItemImpl uses the name to make the element available in the velocity container.

This method is used by a form infrastructure provider.

Specified by:
getName in interface FormItem
Returns:

isInlineEditingOn

public boolean isInlineEditingOn()
Specified by:
isInlineEditingOn in interface InlineElement

setEmptyDisplayText

public FormItem setEmptyDisplayText(java.lang.String i18nKey4Text)
Specified by:
setEmptyDisplayText in interface InlineElement

getEmptyDisplayText

public java.lang.String getEmptyDisplayText()
Specified by:
getEmptyDisplayText in interface InlineElement

getComponent

public Component getComponent()
Description copied from interface: FormItem
The elements panel to be rendered by the GUI Framework.

Specified by:
getComponent in interface FormItem
Returns:
See Also:
org.olat.core.gui.components.form.flexible.FormComponent#getAsComponent()

getRootForm

public Form getRootForm()
Description copied from interface: FormItem
a form item always has a root container where it belongs to. The root container is responsible for the opening and closing HTML FORM tag.

This method must be implemented by a specialised form item provider.

Specified by:
getRootForm in interface FormItem
Returns:
See Also:
org.olat.core.gui.components.form.flexible.FormComponent#getRootForm()

setRootForm

public void setRootForm(Form rootForm)
Specified by:
setRootForm in interface FormItem

setTranslator

public void setTranslator(Translator translator)
Specified by:
setTranslator in interface FormItem

getTranslator

public Translator getTranslator()
Specified by:
getTranslator in interface FormItem
Returns:

getLabelC

public Component getLabelC()
Description copied from interface: FormItem
label panel of the form item, null if no label provided/rendered

This method is used by a form infrastructure provider.

Specified by:
getLabelC in interface FormItem
Returns:

getLabelText

public java.lang.String getLabelText()
Description copied from interface: FormItem
label panel of the form item, null if no label provided/rendered

This method is used by a form infrastructure provider.

Specified by:
getLabelText in interface FormItem
Returns:

setLabel

public void setLabel(java.lang.String label,
                     java.lang.String[] params)
Description copied from interface: FormItem
Key to be translated with the form translator and placed in the label panel.

Specified by:
setLabel in interface FormItem
Parameters:
label - i18n key
params - i18n key parameters

setLabelComponent

public FormItem setLabelComponent(FormItem labelComponent,
                                  FormItemContainer container)
Description copied from interface: FormItem
see setErrorComponent for comments

Specified by:
setLabelComponent in interface FormItem
Parameters:
labelComponent -
container -
Returns:
this

setFocus

public void setFocus(boolean hasFocus)
Description copied from interface: FormItem
true if the element should (try to) get focus, false is default

Specified by:
setFocus in interface FormItem

isMandatory

public boolean isMandatory()
Description copied from interface: FormItem
true if the form item should contain a (valid) value.

Specified by:
isMandatory in interface FormItem
Returns:

hasFocus

public boolean hasFocus()
Description copied from interface: FormItem
true if this element tries to get focus.

Specified by:
hasFocus in interface FormItem
Returns:

setMandatory

public void setMandatory(boolean isMandatory)
Description copied from interface: FormItem
Shows a mandatory icon next to this form item. This is only a GUI cue, it does not activate any validators. It is in the developer's responsibility to validate the form.

Specified by:
setMandatory in interface FormItem
Parameters:
isMandatory - Whether this form item should have a mandatory icon.

getExampleC

public Component getExampleC()
Description copied from interface: FormItem
translated example text, wrapped in component

This method is used by a form infrastructure provider.

Specified by:
getExampleC in interface FormItem
Returns:
See Also:
org.olat.core.gui.components.form.flexible.FormComponent#getExample()

getExampleText

public java.lang.String getExampleText()
Description copied from interface: FormItem

This method is used by a form infrastructure provider.

Specified by:
getExampleText in interface FormItem
Returns:
See Also:
org.olat.core.gui.components.form.flexible.FormComponent#getExampleText()

setExampleKey

public void setExampleKey(java.lang.String exampleKey,
                          java.lang.String[] params)
Description copied from interface: FormItem
key for example with params to fill

Specified by:
setExampleKey in interface FormItem
See Also:
org.olat.core.gui.components.form.flexible.FormComponent#setExampleKey(java.lang.String, java.lang.String[])

setErrorKey

public void setErrorKey(java.lang.String errorKey,
                        java.lang.String[] params)
Description copied from interface: FormItem
Sets the i18n key for this form item's error message and displays the error message if showErro(true) is set.

Specified by:
setErrorKey in interface FormItem
Parameters:
errorKey - i18n key for the error message.
params - Additional error message contents.
See Also:
org.olat.core.gui.components.form.flexible.FormComponent#setErrorKey(java.lang.String, java.lang.String[])

setErrorComponent

public void setErrorComponent(FormItem errorFormItem,
                              FormLayouter container)
Description copied from interface: FormItem
a complex "error" message, or a helper wizard to fix the error.
It must be a form item itself, that starting the fixing workflow let the surrounding form evaluate (intermediate save values).
Typically a FormLink is used here to start a workflow in a modal dialog.
Use showError(true) for the visibility of the error.

Specified by:
setErrorComponent in interface FormItem
container - the container containing the form item which has the error
See Also:
org.olat.core.gui.components.form.flexible.FormComponent#setErrorController(org.olat.core.gui.control.Controller)

getErrorC

public Component getErrorC()
Description copied from interface: FormItem
a complex "error" message, or a helper wizard to fix the error may be

This method is used by a form infrastructure provider. null

Specified by:
getErrorC in interface FormItem
See Also:
org.olat.core.gui.components.form.flexible.FormComponent#getErrorController()

getErrorText

public java.lang.String getErrorText()
Description copied from interface: FormItem

This method is used by a form infrastructure provider.

Specified by:
getErrorText in interface FormItem
Returns:
See Also:
org.olat.core.gui.components.form.flexible.FormComponent#getErrorText()

setEnabled

public void setEnabled(boolean isEnabled)
Description copied from interface: FormItem
item is enabled/disabled, e.g. editable/read only in contrast to setVisible this does NOT DISABLE label, example, error!

Specified by:
setEnabled in interface FormItem

isEnabled

public boolean isEnabled()
Description copied from interface: FormItem
true if item is marked as editable.

Specified by:
isEnabled in interface FormItem
Returns:

setVisible

public void setVisible(boolean isVisible)
Description copied from interface: FormItem
item, label, example, error get not visible

Specified by:
setVisible in interface FormItem

isVisible

public boolean isVisible()
Description copied from interface: FormItem
true if form item was marked visible.

Specified by:
isVisible in interface FormItem

hasError

public boolean hasError()
Specified by:
hasError in interface FormItem
Returns:

hasLabel

public boolean hasLabel()
Specified by:
hasLabel in interface FormItem
Returns:

hasExample

public boolean hasExample()
Specified by:
hasExample in interface FormItem
Returns:

showLabel

public void showLabel(boolean show)
Specified by:
showLabel in interface FormItem

showError

public void showError(boolean show)
Specified by:
showError in interface FormItem

clearError

public void clearError()
Description copied from interface: FormItem
error is resolved, e.g. hasError() should return false and the error component gets invisible (and resetted)

Specified by:
clearError in interface FormItem

showExample

public void showExample(boolean show)
Specified by:
showExample in interface FormItem

addActionListener

public void addActionListener(Controller listener,
                              int action)
Specified by:
addActionListener in interface FormItem
See Also:
org.olat.core.gui.components.form.flexible.FormItem#addActionListenerFor(org.olat.core.gui.control.Controller, int)

getActionListenersFor

public java.util.List getActionListenersFor(int event)
Specified by:
getActionListenersFor in interface FormItem
Returns:

getAction

public int getAction()
Specified by:
getAction in interface FormItem
Returns:

evalFormRequest

public abstract void evalFormRequest(UserRequest ureq)
gets called if the implementing component is part of a form which gets partly submitted -> extract data for you and store it temporarly for redisplay without a validation

Specified by:
evalFormRequest in interface FormItem
Parameters:
ureq -

doDispatchFormRequest

public void doDispatchFormRequest(UserRequest ureq)
gets called if the implementing component was clicked.

Specified by:
doDispatchFormRequest in interface FormItem
Parameters:
ureq -
formId -

getUserObject

public java.lang.Object getUserObject()
Specified by:
getUserObject in interface FormItem
Returns:
See Also:
org.olat.core.gui.components.form.flexible.api.FormItem#getUserObject()

setUserObject

public void setUserObject(java.lang.Object userObject)
Specified by:
setUserObject in interface FormItem
See Also:
org.olat.core.gui.components.form.flexible.api.FormItem#setUserObject(java.lang.Object)

getFormDispatchId

public java.lang.String getFormDispatchId()
Description copied from interface: FormBaseComponentIdProvider
A String containing a unique ID per form element component on the screen. This is corresponding to the Component#getDispatchID() and should achieve the same for the form elements.

Specified by:
getFormDispatchId in interface FormBaseComponentIdProvider
Returns:

validate

public abstract void validate(java.util.List validationResults)
Description copied from interface: FormItem
validate the data in the field, create error messages or update any component.

This method must be implemented by a specialised form item provider.

Specified by:
validate in interface FormItem
See Also:
org.olat.core.gui.components.form.flexible.FormComponent#validate(java.util.List)

reset

public abstract void reset()
Description copied from interface: FormItem
reset the data in the field to a initial/predefined value. This method is called if in a form a reset request is issued. It is the counterpart to the validate call which

Specified by:
reset in interface FormItem
See Also:
FormItem.reset()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object