org.araneaframework.uilib.form
Class GenericFormElement

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
All Implemented Interfaces:
ApplicationComponent, ApplicationService, ApplicationWidget, Component, Composite, Composite.CompositeComponent, Composite.CompositeService, Composite.CompositeWidget, Serializable, Service, Viewable, Viewable.ViewableComponent, Viewable.ViewableService, Viewable.ViewableWidget, Widget
Direct Known Subclasses:
BaseFormListWidget, FormElement, FormWidget

public abstract class GenericFormElement
extends BaseApplicationWidget

Represents a general form element, a node in form element hierarchy.

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

Nested Class Summary
 class GenericFormElement.ViewModel
          This class represents a 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  Boolean backgroundValidation
           
protected  Constraint constraint
           
protected  boolean converted
           
protected  Map properties
           
static String SEAMLESS_VALIDATION_ACTION_ID
           
protected  boolean 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
GenericFormElement()
           
 
Method Summary
abstract  void accept(String id, FormElementVisitor visitor)
          Accepts the visitor.
 void addError(String error)
           
 void addErrors(Set errors)
           
 void clearErrors()
          Clears element errors.
 void convert()
          Converts the value from Controls to Data.
 boolean convertAndValidate()
          Converts the element value from control to data item and validates the value.
protected abstract  void convertInternal()
          Converts the element value from control to data item
 Constraint getConstraint()
          Returns element constraint.
 Environment getConstraintEnvironment()
           
 Set getErrors()
          Since 1.1 this returns an immutable Set.
protected  MessageContext getMessageCtx()
           
protected  Set getMutableErrors()
           
 Map getProperties()
          Returns all properties of the element as a map (string -> string).
 Object getProperty(Object key)
          Returns the value of the property.
 Object getValue()
           
protected  void init()
          Init callback.
 boolean isBackgroundValidation()
           
abstract  boolean isDisabled()
          Returns whether the element is disabled.
 boolean isEvaluated()
          Returns whether last evaluation (converting and optional validating) has succeeded.
abstract  boolean isStateChanged()
          Returns whether data item state has changed after it was marked.
 boolean isValid()
          Returns whether the element is valid.
abstract  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().
abstract  void restoreBaseState()
          Restores the value of the data item from the marked base state.
 void setBackgroundValidation(boolean b)
           
 void setConstraint(Constraint constraint)
          Sets element constraint.
abstract  void setDisabled(boolean disabled)
          Sets wether the element is disabled.
 void setProperty(Object key, Object value)
          Method for setting property values.
 boolean validate()
          Validates the element.
protected  boolean validateInternal()
          Validates the element.
 
Methods inherited from class org.araneaframework.core.BaseApplicationWidget
_getComposite, _getViewable, action, addActionListener, addEventListener, addWidget, addWidget, clearActionListeners, clearEventlisteners, clearGlobalEventListener, disableWidget, enableWidget, event, getActionId, getChildEnvironment, getChildren, getChildWidgetEnvironment, getEnvironment, getEventId, getViewModel, 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.Component
_getComponent, getScope, isAlive
 
Methods inherited from interface org.araneaframework.Service
_getService
 
Methods inherited from interface org.araneaframework.Widget
_getWidget
 

Field Detail

SEAMLESS_VALIDATION_ACTION_ID

public static final String SEAMLESS_VALIDATION_ACTION_ID
Since:
1.1
See Also:
Constant Field Values

constraint

protected Constraint constraint

properties

protected Map properties

converted

protected boolean converted

validated

protected boolean validated

backgroundValidation

protected Boolean backgroundValidation
Constructor Detail

GenericFormElement

public GenericFormElement()
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 BaseComponent
Throws:
Exception - Any runtime exception that may occur.

getProperties

public Map getProperties()
Returns all properties of the element as a map (string -> string).

Returns:
all properties as a map.

setProperty

public void setProperty(Object key,
                        Object value)
Method for setting property values.

Parameters:
key - name of the property to be set.
value - value for the property.

getProperty

public Object getProperty(Object key)
Returns the value of the property.

Parameters:
key - the name of the property to get.
Returns:
the value of the property, null if property is not defined.

getConstraint

public Constraint getConstraint()
Returns element constraint.

Returns:
element constraint.

setConstraint

public void setConstraint(Constraint constraint)
Sets element constraint.

Parameters:
constraint - The constraint to set.

getConstraintEnvironment

public Environment getConstraintEnvironment()

isValid

public boolean isValid()
Returns whether the element is valid.

Returns:
whether the element is valid.

convertAndValidate

public boolean convertAndValidate()
Converts the element value from control to data item and validates the value.

Returns:
whether the element is valid.

convert

public void convert()
Converts the value from Controls to Data.


validate

public boolean validate()
Validates the element.

Returns:
whether the element is valid.

isEvaluated

public boolean isEvaluated()
Returns whether last evaluation (converting and optional validating) has succeeded.

Returns:
whether last evaluation (converting and optional validating) has succeeded.

getErrors

public Set getErrors()
Since 1.1 this returns an immutable Set.


addError

public void addError(String error)

addErrors

public void addErrors(Set errors)

clearErrors

public void clearErrors()
Clears element errors.


getValue

public Object getValue()

setBackgroundValidation

public void setBackgroundValidation(boolean b)
Since:
1.1

isBackgroundValidation

public boolean isBackgroundValidation()
Since:
1.1

markBaseState

public abstract 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().


restoreBaseState

public abstract void restoreBaseState()
Restores the value of the data item from the marked base state.


isStateChanged

public abstract boolean isStateChanged()
Returns whether data item state has changed after it was marked.

Returns:
whether data item state has changed after it was marked.

setDisabled

public abstract void setDisabled(boolean disabled)
Sets wether the element is disabled.

Parameters:
disabled - wether the element is disabled.

isDisabled

public abstract boolean isDisabled()
Returns whether the element is disabled.

Returns:
whether the element is disabled.

accept

public abstract void accept(String id,
                            FormElementVisitor visitor)
Accepts the visitor.


getMessageCtx

protected MessageContext getMessageCtx()
Since:
1.1 this method is protected (private before 1.1).

convertInternal

protected abstract void convertInternal()
                                 throws Exception
Converts the element value from control to data item

Throws:
Exception

validateInternal

protected boolean validateInternal()
                            throws Exception
Validates the element.

Returns:
whether the element is valid.
Throws:
Exception

getMutableErrors

protected Set getMutableErrors()
Since:
1.1