org.araneaframework.uilib.form
Class FormElement

java.lang.Object
  extended byorg.araneaframework.core.BaseComponent
      extended byorg.araneaframework.core.BaseService
          extended byorg.araneaframework.core.BaseWidget
              extended byorg.araneaframework.core.BaseApplicationWidget
                  extended byorg.araneaframework.uilib.form.GenericFormElement
                      extended byorg.araneaframework.uilib.form.FormElement
All Implemented Interfaces:
ApplicationComponent, ApplicationService, ApplicationWidget, Component, Composite, Composite.CompositeComponent, Composite.CompositeService, Composite.CompositeWidget, FormElementContext, RenderStateAware, Serializable, Service, Viewable, Viewable.ViewableComponent, Viewable.ViewableService, Viewable.ViewableWidget, Widget

public class FormElement
extends GenericFormElement
implements FormElementContext, RenderStateAware

Represents a simple "leaf" form element that holds a Control and its Data.

Author:
Jevgeni Kabanov (ekabanov at araneaframework dot org)
See Also:
Serialized Form

Nested Class Summary
 class FormElement.ViewModel
          Represents a simple form element view model.
 
Nested classes inherited from class org.araneaframework.core.BaseApplicationWidget
BaseApplicationWidget.CompositeImpl, BaseApplicationWidget.ViewableImpl
 
Nested classes inherited from class org.araneaframework.core.BaseWidget
BaseWidget.WidgetImpl
 
Nested classes inherited from class org.araneaframework.core.BaseService
BaseService.ServiceImpl
 
Nested classes inherited from class org.araneaframework.core.BaseComponent
BaseComponent.ComponentImpl
 
Nested classes inherited from class org.araneaframework.core.ApplicationWidget
ApplicationWidget.WidgetViewModel
 
Nested classes inherited from class org.araneaframework.core.ApplicationService
ApplicationService.ServiceViewModel
 
Nested classes inherited from class org.araneaframework.core.ApplicationComponent
ApplicationComponent.ComponentViewModel
 
Nested classes inherited from class org.araneaframework.Component
Component.Interface
 
Nested classes inherited from class org.araneaframework.Composite
Composite.CompositeComponent, Composite.CompositeService, Composite.CompositeWidget, Composite.Interface
 
Nested classes inherited from class org.araneaframework.Viewable
Viewable.Interface, Viewable.ViewableComponent, Viewable.ViewableService, Viewable.ViewableWidget
 
Nested classes inherited from class org.araneaframework.Service
Service.Interface
 
Nested classes inherited from class org.araneaframework.Widget
Widget.Interface
 
Field Summary
protected  Control control
           
protected  Converter converter
           
protected  Data data
           
protected  boolean disabled
           
static String ERROR_RENDERER_PROPERTY_KEY
          The property key for custom FormElementValidationErrorRenderer that may be set for this FormElement.
protected  String label
           
protected  boolean mandatory
           
 
Fields inherited from class org.araneaframework.uilib.form.GenericFormElement
backgroundValidation, constraint, converted, properties, SEAMLESS_VALIDATION_ACTION_ID, validated
 
Fields inherited from class org.araneaframework.core.BaseService
currentInputData, currentOutputData
 
Fields inherited from interface org.araneaframework.core.ApplicationWidget
EVENT_HANDLER_ID_KEY, EVENT_PARAMETER_KEY, EVENT_PATH_KEY
 
Fields inherited from interface org.araneaframework.core.ApplicationService
ACTION_HANDLER_ID_KEY, ACTION_PARAMETER_KEY, ACTION_PATH_KEY
 
Constructor Summary
FormElement()
           
 
Method Summary
 void _setRendered(boolean rendered)
          Only use when you really know what you are doing.
 void accept(String id, FormElementVisitor visitor)
          Accepts the visitor.
protected  void action(Path path, InputData input, OutputData output)
          If Path.hasNext() routes to the action to child, otherwise calls the appropriate ActionListener.
 void addError(String error)
           
 void addInitEvent(Event event)
           
 void clearErrors()
          Clears element errors.
protected  void convertInternal()
          Uses BaseConverterto convert the BaseControlvalue to the Datavalue.
protected  void destroy()
          Destroy callback.
protected  void destroyControl()
           
protected  void event(Path path, InputData input)
          If path hasNextStep() routes to the correct child, otherwise calls the appropriate listener.
 Converter findConverter()
          Finds a BaseConvertercorresponding to current control and data item.
 Environment getConstraintEnvironment()
           
 Control getControl()
          Returns Control.
 Converter getConverter()
          Returns BaseConverter.
 Data getData()
          Returns Data.
protected  FormElementValidationActionListener getDefaultBackgroundValidationListener()
          Returns new instance of FormElementValidationActionListener tied to this FormElement.
 FormElementValidationErrorRenderer getFormElementValidationErrorRenderer()
           
 String getLabel()
          Returns control label.
 Object getValue()
           
 Object getViewModel()
          Returns FormElement.ViewModel.
protected  void handleAction(InputData input, OutputData output)
          Calls the approriate listener
protected  void init()
          Init callback.
 boolean isDisabled()
          Returns whether the element is disabled.
protected  boolean isIgnoreEvents()
          When this returns true,
 boolean isMandatory()
           
 boolean isRead()
          Returns whether the form element was present in the last request.
 boolean isRendered()
          Returns whether this GenericFormElement was rendered in response.
 boolean isStateChanged()
          Returns whether data item state has changed after it was marked.
 void markBaseState()
          Marks the current value of the data item as the base state that will be used to determine whether its state has changed in isStateChanged().
 void rendered()
          Marks status of this FormElement rendered.
 void restoreBaseState()
          Restores the value of the data item from the marked base state.
protected  void runInitEvents()
          Called from init() to run queued events.
 void setBackgroundValidationListener(ActionListener actionListener)
          Sets the action listener that deals with background validation of form.
 void setControl(Control control)
          Sets Control.
 void setConverter(Converter converter)
          Sets BaseConverter.
 void setData(Data data)
          Sets Data.
 void setDisabled(boolean disabled)
          Sets wether the element is disabled.
 void setFormElementValidationErrorRenderer(FormElementValidationErrorRenderer renderer)
           
protected  void setIgnoreEvents(boolean ignoreEvents)
          When set
 void setLabel(String label)
          Sets control label.
 void setMandatory(boolean mandatory)
           
 void setValue(Object value)
           
protected  void update(InputData input)
           
protected  boolean validateInternal()
          Validates the element.
 
Methods inherited from class org.araneaframework.uilib.form.GenericFormElement
addErrors, convert, convertAndValidate, getConstraint, getErrors, getMessageCtx, getMutableErrors, getProperties, getProperty, isBackgroundValidation, isEvaluated, isValid, setBackgroundValidation, setConstraint, setProperty, validate
 
Methods inherited from class org.araneaframework.core.BaseApplicationWidget
_getComposite, _getViewable, addActionListener, addEventListener, addWidget, addWidget, clearActionListeners, clearEventlisteners, clearGlobalEventListener, disableWidget, enableWidget, getActionId, getChildEnvironment, getChildren, getChildWidgetEnvironment, getEnvironment, getEventId, getWidget, handleEvent, handleUpdate, propagate, putViewData, putViewDataOnce, removeActionListener, removeEventListener, removeViewData, removeWidget, render, setGlobalEventListener
 
Methods inherited from class org.araneaframework.core.BaseWidget
_getWidget, getInputData, getOutputData, handleWidgetException
 
Methods inherited from class org.araneaframework.core.BaseService
_getService, handleServiceException
 
Methods inherited from class org.araneaframework.core.BaseComponent
_addComponent, _addComponent, _checkCall, _disableComponent, _enableComponent, _endCall, _endWaitingCall, _getChildren, _getComponent, _getDisabledChildren, _propagate, _relocateComponent, _removeComponent, _setEnvironment, _setScope, _startCall, _startWaitingCall, _strictCheckCall, _strictStartCall, _waitNoCall, disable, enable, getScope, handleException, isAlive, isDead, isInitialized
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.araneaframework.uilib.form.FormElementContext
addErrors, getEnvironment, isValid
 
Methods inherited from interface org.araneaframework.Component
_getComponent, getScope, isAlive
 
Methods inherited from interface org.araneaframework.Service
_getService
 
Methods inherited from interface org.araneaframework.Widget
_getWidget
 

Field Detail

ERROR_RENDERER_PROPERTY_KEY

public static final String ERROR_RENDERER_PROPERTY_KEY
The property key for custom FormElementValidationErrorRenderer that may be set for this FormElement.

Since:
1.1
See Also:
Constant Field Values

control

protected Control control

converter

protected Converter converter

data

protected Data data

label

protected String label

mandatory

protected boolean mandatory

disabled

protected boolean disabled
Constructor Detail

FormElement

public FormElement()
Method Detail

getLabel

public String getLabel()
Returns control label.

Specified by:
getLabel in interface FormElementContext
Returns:
control label.

setLabel

public void setLabel(String label)
Sets control label.

Parameters:
label - control label.

getConverter

public Converter getConverter()
Returns BaseConverter.

Specified by:
getConverter in interface FormElementContext
Returns:
the BaseConverter.

setConverter

public void setConverter(Converter converter)
Sets BaseConverter.

Parameters:
converter - The BaseConverterto set.

getData

public Data getData()
Returns Data.

Returns:
Data.

setData

public void setData(Data data)
Sets Data.

Parameters:
data - Data.

getControl

public Control getControl()
Returns Control.

Specified by:
getControl in interface FormElementContext
Returns:
Control.

setControl

public void setControl(Control control)
Sets Control.

Parameters:
control - Control.

destroyControl

protected void destroyControl()
Since:
1.1

findConverter

public Converter findConverter()
Finds a BaseConvertercorresponding to current control and data item.

Throws:
ConverterNotFoundException - if converter cannot be found.

isRead

public boolean isRead()
Returns whether the form element was present in the last request.

Specified by:
isRead in interface FormElementContext
Returns:
whether the form element was present in the last request.

setDisabled

public void setDisabled(boolean disabled)
Description copied from class: GenericFormElement
Sets wether the element is disabled.

Specified by:
setDisabled in class GenericFormElement
Parameters:
disabled - wether the element is disabled.

isDisabled

public boolean isDisabled()
Description copied from class: GenericFormElement
Returns whether the element is disabled.

Specified by:
isDisabled in interface FormElementContext
Specified by:
isDisabled in class GenericFormElement
Returns:
whether the element is disabled.

markBaseState

public void markBaseState()
Description copied from class: GenericFormElement
Marks the current value of the data item as the base state that will be used to determine whether its state has changed in GenericFormElement.isStateChanged().

Specified by:
markBaseState in class GenericFormElement

restoreBaseState

public void restoreBaseState()
Description copied from class: GenericFormElement
Restores the value of the data item from the marked base state.

Specified by:
restoreBaseState in class GenericFormElement

isStateChanged

public boolean isStateChanged()
Description copied from class: GenericFormElement
Returns whether data item state has changed after it was marked.

Specified by:
isStateChanged in class GenericFormElement
Returns:
whether data item state has changed after it was marked.

getValue

public Object getValue()
Specified by:
getValue in interface FormElementContext
Overrides:
getValue in class GenericFormElement

setValue

public void setValue(Object value)

isMandatory

public boolean isMandatory()
Specified by:
isMandatory in interface FormElementContext

setMandatory

public void setMandatory(boolean mandatory)

addError

public void addError(String error)
Specified by:
addError in interface FormElementContext
Overrides:
addError in class GenericFormElement

clearErrors

public void clearErrors()
Description copied from class: GenericFormElement
Clears element errors.

Overrides:
clearErrors in class GenericFormElement

setBackgroundValidationListener

public void setBackgroundValidationListener(ActionListener actionListener)
Sets the action listener that deals with background validation of form. It should be used when custom background validation logic or behaviour is wanted. Just for using default FormElementValidationActionListener, only GenericFormElement.setBackgroundValidation(boolean) needs to be called with parameter true.

Parameters:
actionListener - custom listener that should handle validation of this FormElement
Since:
1.1

getFormElementValidationErrorRenderer

public FormElementValidationErrorRenderer getFormElementValidationErrorRenderer()
Returns:
FormElementValidationErrorRenderer which will take care of rendering validation error messages produced by this FormElement.
Since:
1.1

setFormElementValidationErrorRenderer

public void setFormElementValidationErrorRenderer(FormElementValidationErrorRenderer renderer)
Since:
1.1

update

protected void update(InputData input)
               throws Exception
Overrides:
update in class BaseApplicationWidget
Throws:
Exception

action

protected void action(Path path,
                      InputData input,
                      OutputData output)
               throws Exception
Description copied from class: BaseApplicationWidget
If Path.hasNext() routes to the action to child, otherwise calls the appropriate ActionListener.

Overrides:
action in class BaseApplicationWidget
Throws:
Exception

event

protected void event(Path path,
                     InputData input)
              throws Exception
Description copied from class: BaseApplicationWidget
If path hasNextStep() routes to the correct child, otherwise calls the appropriate listener.

Overrides:
event in class BaseApplicationWidget
Throws:
Exception

handleAction

protected void handleAction(InputData input,
                            OutputData output)
                     throws Exception
Description copied from class: BaseApplicationWidget
Calls the approriate listener

Overrides:
handleAction in class BaseApplicationWidget
Throws:
Exception

getConstraintEnvironment

public Environment getConstraintEnvironment()
Overrides:
getConstraintEnvironment in class GenericFormElement

getViewModel

public Object getViewModel()
                    throws Exception
Returns FormElement.ViewModel.

Overrides:
getViewModel in class BaseApplicationWidget
Returns:
FormElement.ViewModel.
Throws:
Exception

addInitEvent

public void addInitEvent(Event event)
Since:
1.0.5

init

protected void init()
             throws Exception
Description copied from class: BaseComponent
Init callback. Gets called when the component is initilized.

Overrides:
init in class GenericFormElement
Throws:
Exception

getDefaultBackgroundValidationListener

protected FormElementValidationActionListener getDefaultBackgroundValidationListener()
Returns new instance of FormElementValidationActionListener tied to this FormElement.

Since:
1.1

destroy

protected void destroy()
                throws Exception
Description copied from class: BaseComponent
Destroy callback. Gets called when the component is destroyed.

Overrides:
destroy in class BaseComponent
Throws:
Exception - Any runtime exception that may occur.

convertInternal

protected void convertInternal()
Uses BaseConverterto convert the BaseControlvalue to the Datavalue.

Specified by:
convertInternal in class GenericFormElement

validateInternal

protected boolean validateInternal()
                            throws Exception
Description copied from class: GenericFormElement
Validates the element.

Overrides:
validateInternal in class GenericFormElement
Returns:
whether the element is valid.
Throws:
Exception

accept

public void accept(String id,
                   FormElementVisitor visitor)
Description copied from class: GenericFormElement
Accepts the visitor.

Specified by:
accept in class GenericFormElement

runInitEvents

protected void runInitEvents()
Called from init() to run queued events.

Since:
1.0.5

isRendered

public boolean isRendered()
Returns whether this GenericFormElement was rendered in response. Only formelements that were rendered should be read from request.

Specified by:
isRendered in interface RenderStateAware
Returns:
whether this GenericFormElement was rendered

rendered

public void rendered()
Marks status of this FormElement rendered. Only rendered FormElements may read the data from subsequent request.


_setRendered

public void _setRendered(boolean rendered)
Description copied from interface: RenderStateAware
Only use when you really know what you are doing.

Specified by:
_setRendered in interface RenderStateAware
Parameters:
rendered -
Since:
1.1

isIgnoreEvents

protected boolean isIgnoreEvents()
When this returns true,

Since:
1.1

setIgnoreEvents

protected void setIgnoreEvents(boolean ignoreEvents)
When set

Since:
1.1