org.araneaframework.uilib.form
Class FormWidget

java.lang.Object
  extended by org.araneaframework.core.BaseComponent
      extended by org.araneaframework.core.BaseService
          extended by org.araneaframework.core.BaseWidget
              extended by org.araneaframework.core.BaseApplicationWidget
                  extended by org.araneaframework.uilib.form.GenericFormElement
                      extended by org.araneaframework.uilib.form.FormWidget
All Implemented Interfaces:
Serializable, Component, Composite, Composite.CompositeComponent, Composite.CompositeService, Composite.CompositeWidget, ApplicationComponent, ApplicationService, ApplicationWidget, Service, FormContext, Viewable, Viewable.ViewableComponent, Viewable.ViewableService, Viewable.ViewableWidget, Widget
Direct Known Subclasses:
BeanFormWidget

public class FormWidget
extends GenericFormElement
implements FormContext

This class represents a form element that can contain other form elements.

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

Nested Class Summary
 class FormWidget.ViewModel
          Represents a composite form element view model.
 
Nested classes/interfaces inherited from class org.araneaframework.core.BaseApplicationWidget
BaseApplicationWidget.CompositeImpl, BaseApplicationWidget.ViewableImpl
 
Nested classes/interfaces inherited from class org.araneaframework.core.BaseWidget
BaseWidget.WidgetImpl
 
Nested classes/interfaces inherited from class org.araneaframework.core.BaseService
BaseService.ServiceImpl
 
Nested classes/interfaces inherited from class org.araneaframework.core.BaseComponent
BaseComponent.ComponentImpl
 
Nested classes/interfaces inherited from interface org.araneaframework.core.ApplicationWidget
ApplicationWidget.WidgetViewModel
 
Nested classes/interfaces inherited from interface org.araneaframework.core.ApplicationService
ApplicationService.ServiceViewModel
 
Nested classes/interfaces inherited from interface org.araneaframework.core.ApplicationComponent
ApplicationComponent.ComponentViewModel
 
Nested classes/interfaces inherited from interface org.araneaframework.Composite
Composite.CompositeComponent, Composite.CompositeService, Composite.CompositeWidget
 
Nested classes/interfaces inherited from interface org.araneaframework.Viewable
Viewable.ViewableComponent, Viewable.ViewableService, Viewable.ViewableWidget
 
Nested classes/interfaces inherited from interface org.araneaframework.Widget
Widget.Interface
 
Field Summary
protected  LinkedMap elements
           
 
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
FormWidget()
           
 
Method Summary
 void accept(String id, FormElementVisitor visitor)
          Accepts the visitor.
 void addElement(String id, GenericFormElement element)
          Adds a contained element.
 FormElement addElement(String elementName, String labelId, Control control, Data data, boolean mandatory)
          This method adds a FormElement to this FormWidget.
 FormElement addElement(String elementName, String labelId, Control control, Data data, Object initialValue, boolean mandatory)
          This method adds a FormElement to this FormWidget.
 void addElementAfter(String id, GenericFormElement element, String afterId)
          Adds a contained element with given id after the element with specified id.
 void addElementBefore(String id, GenericFormElement element, String beforeId)
          Adds a contained element with given id before the element with specified id.
 void addError(String error)
           
 FormWidget addSubForm(String id)
          Adds a new subform to this FormWidget.
 void clearErrors()
          Clears element errors.
protected  void convertInternal()
          Calls GenericFormElement.convert() for all contained elements.
 FormElement createElement(String labelId, Control control, Data data, boolean mandatory)
          This method makes a FormElement with given Control and Data.
 FormElement createElement(String labelId, Control control, Data data, Object initialValue, boolean mandatory)
          This method makes a FormElement with given Control and Data.
protected  Environment getChildWidgetEnvironment()
          Returns the widget's Environment by default.
 Control getControlByFullName(String fullName)
          Returns composite form element specified by full name.
 GenericFormElement getElement(String elementName)
          Returns a contained element by its name.
 FormElement getElementByFullName(String fullName)
          Returns simple form element specified by full name.
 Map getElements()
          Returns elements.
 GenericFormElement getGenericElementByFullName(String fullName)
          Returns form element specified by full name.
 FormWidget getSubFormByFullName(String fullName)
          Returns simple form element specified by full name.
 Object getValueByFullName(String fullName)
          Returns form element value specified by full name.
 Object getViewModel()
          Returns FormWidget.ViewModel.
protected  void init()
          Init callback.
 boolean isDisabled()
          Returns whether the element is disabled.
 boolean isStateChanged()
          Returns whether data item state has changed after it was marked.
 boolean isValid()
          Returns whether the element is valid.
 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 GenericFormElement.isStateChanged().
 void removeElement(String id)
          Removes a contained element by its name.
 void restoreBaseState()
          Restores the value of the data item from the marked base state.
 void setDisabled(boolean disabled)
          Sets wether the element is disabled.
 void setValueByFullName(String fullName, Object value)
          Sets form element value specified by full name.
protected  boolean validateInternal()
          Controls that the constraints and all subcontrols are valid.
 
Methods inherited from class org.araneaframework.uilib.form.GenericFormElement
addErrors, convert, convertAndValidate, getConstraint, getConstraintEnvironment, getErrors, getMessageCtx, getMutableErrors, getProperties, getProperty, getValue, isBackgroundValidation, isEvaluated, setBackgroundValidation, setConstraint, setProperty, validate
 
Methods inherited from class org.araneaframework.core.BaseApplicationWidget
_getComposite, _getViewable, action, addActionListener, addEventListener, addWidget, addWidget, clearActionListeners, clearEventlisteners, clearGlobalEventListener, disableWidget, enableWidget, event, getActionId, getChildEnvironment, getChildren, getEnvironment, getEventId, getWidget, handleAction, handleEvent, handleUpdate, propagate, putViewData, putViewDataOnce, removeActionListener, removeEventListener, removeViewData, removeWidget, render, setGlobalEventListener, update
 
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, destroy, 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.FormContext
getProperties, isBackgroundValidation
 
Methods inherited from interface org.araneaframework.Widget
_getWidget
 
Methods inherited from interface org.araneaframework.Service
_getService
 
Methods inherited from interface org.araneaframework.Component
_getComponent, getScope, isAlive
 

Field Detail

elements

protected LinkedMap elements
Constructor Detail

FormWidget

public FormWidget()
Method Detail

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 - Any runtime exception that may occur.

getChildWidgetEnvironment

protected Environment getChildWidgetEnvironment()
                                         throws Exception
Description copied from class: BaseApplicationWidget
Returns the widget's Environment by default. Usually overridden.

Overrides:
getChildWidgetEnvironment in class BaseApplicationWidget
Throws:
Exception

clearErrors

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

Overrides:
clearErrors in class GenericFormElement

isValid

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

Overrides:
isValid in class GenericFormElement
Returns:
whether the element is valid.

getElement

public GenericFormElement getElement(String elementName)
Returns a contained element by its name.

Parameters:
elementName - contained element name
Returns:
a contained element by its name.

addElementAfter

public void addElementAfter(String id,
                            GenericFormElement element,
                            String afterId)
Adds a contained element with given id after the element with specified id.

Parameters:
id - added element id
element - added element
afterId - element id after which contained element should be added

addElementBefore

public void addElementBefore(String id,
                             GenericFormElement element,
                             String beforeId)
Adds a contained element with given id before the element with specified id. Should be only used in RARE cases where internal order of elements matters for some reason.

Parameters:
id - added element id
element - added element
beforeId - element id before which contained element should be added

addElement

public void addElement(String id,
                       GenericFormElement element)
Adds a contained element.

Parameters:
element - contained element.
id - element id

removeElement

public void removeElement(String id)
Removes a contained element by its name.


getElements

public Map getElements()
Returns elements.

Returns:
elements.

convertInternal

protected void convertInternal()
                        throws Exception
Calls GenericFormElement.convert() for all contained elements.

Specified by:
convertInternal in class GenericFormElement
Throws:
Exception

validateInternal

protected boolean validateInternal()
                            throws Exception
Controls that the constraints and all subcontrols are valid.

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

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.

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 class GenericFormElement
Returns:
whether the element is disabled.

accept

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

Specified by:
accept in class GenericFormElement

addSubForm

public FormWidget addSubForm(String id)
Adds a new subform to this FormWidget.

Parameters:
id - subform id.
Returns:
created subform

createElement

public FormElement createElement(String labelId,
                                 Control control,
                                 Data data,
                                 Object initialValue,
                                 boolean mandatory)
This method makes a FormElement with given Control and Data.

Parameters:
labelId - localized label id
control - the type of control
data - the type of data
initialValue - initial value for data
mandatory - whether the element must be filled in
Returns:
FormElement with given configuration

createElement

public FormElement createElement(String labelId,
                                 Control control,
                                 Data data,
                                 boolean mandatory)
This method makes a FormElement with given Control and Data.

Parameters:
labelId - id of the localized label.
control - the type of control data.
data - the type of data.
mandatory - whether the element must be present in request.
Returns:
FormElement with given configuration

addElement

public FormElement addElement(String elementName,
                              String labelId,
                              Control control,
                              Data data,
                              boolean mandatory)
This method adds a FormElement to this FormWidget.

Parameters:
elementName - the name of the form element.
labelId - id of the localized label.
control - the type of control data.
data - the type of data.
mandatory - whether the element must be present in request.

addElement

public FormElement addElement(String elementName,
                              String labelId,
                              Control control,
                              Data data,
                              Object initialValue,
                              boolean mandatory)
This method adds a FormElement to this FormWidget.

Parameters:
elementName - the name of the form element.
labelId - id of the localized label.
control - the type of control data.
data - the type of data.
mandatory - whether the element must be present in request.

getGenericElementByFullName

public GenericFormElement getGenericElementByFullName(String fullName)
Returns form element specified by full name.

Parameters:
fullName - The full dot-separated name of the form element.
Returns:
form element specified by full name.

getElementByFullName

public FormElement getElementByFullName(String fullName)
Returns simple form element specified by full name.

Parameters:
fullName - The full dot-separated name of the form element.
Returns:
simple form element specified by full name.

getSubFormByFullName

public FormWidget getSubFormByFullName(String fullName)
Returns simple form element specified by full name.

Parameters:
fullName - The full dot-separated name of the form element.
Returns:
simple form element specified by full name.

getControlByFullName

public Control getControlByFullName(String fullName)
Returns composite form element specified by full name.

Parameters:
fullName - The full dot-separated name of the form element.
Returns:
composite form element specified by full name.

getValueByFullName

public Object getValueByFullName(String fullName)
Returns form element value specified by full name.

Parameters:
fullName - The full dot-separated name of the form element.
Returns:
form element value specified by full name.

setValueByFullName

public void setValueByFullName(String fullName,
                               Object value)
Sets form element value specified by full name.

Parameters:
fullName - The full dot-separated name of the form element.
value - form element value specified by full name.

addError

public void addError(String error)
Overrides:
addError in class GenericFormElement

getViewModel

public Object getViewModel()
Returns FormWidget.ViewModel.

Overrides:
getViewModel in class BaseApplicationWidget
Returns:
FormWidget.ViewModel.