org.araneaframework.uilib.form.control
Class SelectControl

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.control.BaseControl
                      extended byorg.araneaframework.uilib.form.control.StringArrayRequestControl
                          extended byorg.araneaframework.uilib.form.control.StringRequestControl
                              extended byorg.araneaframework.uilib.form.control.EmptyStringNullableControl
                                  extended byorg.araneaframework.uilib.form.control.StringValueControl
                                      extended byorg.araneaframework.uilib.form.control.SelectControl
All Implemented Interfaces:
ApplicationComponent, ApplicationService, ApplicationWidget, Component, Composite, Composite.CompositeComponent, Composite.CompositeService, Composite.CompositeWidget, Control, DisplayItemContainer, FormElementAware, Serializable, Service, Viewable, Viewable.ViewableComponent, Viewable.ViewableService, Viewable.ViewableWidget, Widget

public class SelectControl
extends StringValueControl
implements DisplayItemContainer

This class represents a selectbox (aka dropdown) control.

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

Nested Class Summary
 class SelectControl.ViewModel
           
 
Nested classes inherited from class org.araneaframework.uilib.form.control.BaseControl
BaseControl.WidgetImpl
 
Nested classes inherited from class org.araneaframework.core.BaseApplicationWidget
BaseApplicationWidget.CompositeImpl, BaseApplicationWidget.ViewableImpl
 
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.Widget
Widget.Interface
 
Nested classes inherited from class org.araneaframework.Viewable
Viewable.Interface, Viewable.ViewableComponent, Viewable.ViewableService, Viewable.ViewableWidget
 
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.Composite
Composite.CompositeComponent, Composite.CompositeService, Composite.CompositeWidget, Composite.Interface
 
Field Summary
protected  List items
          A list of DisplayItems.
 
Fields inherited from class org.araneaframework.uilib.form.control.StringArrayRequestControl
eventHelper
 
Fields inherited from class org.araneaframework.uilib.form.control.BaseControl
innerData, isReadFromRequest, value
 
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
SelectControl()
           
 
Method Summary
 void addDisplayItems(Collection beanCollection, String valueName, String labelName)
          Deprecated. use addFromBeanCollection(Collection, String, String) instead
 void addFromBeanCollection(Collection beanCollection, String valueName, String displayStringName)
          Creates DisplayItems corresponding to beans in beanCollection and adds these to this SelectControl.
 void addFromBeanCollection(Collection beanCollection, String valueName, org.apache.commons.collections.Transformer displayTransformer)
          Creates DisplayItems corresponding to beans in beanCollection and adds these to this SelectControl.
 void addFromBeanCollection(Collection beanCollection, org.apache.commons.collections.Transformer valueTransformer, String displayStringName)
          Creates DisplayItems corresponding to beans in beanCollection and adds these to this SelectControl.
 void addFromBeanCollection(Collection beanCollection, org.apache.commons.collections.Transformer valueTransformer, org.apache.commons.collections.Transformer displayTransformer)
          Creates DisplayItems corresponding to beans in beanCollection and adds these to this SelectControl.
 void addItem(DisplayItem item)
          Adds a select-item to the element.
 void addItems(Collection items)
          Adds a display-items to the element.
 void clearItems()
          Clears the list of select-items.
 List getDisplayItems()
          Returns a List <DisplayItem> that this DisplayItemContainer currently helds.
 DisplayItem getSelectedItem()
          Returns DisplayItem corresponding to selected element.
 int getValueIndex(String value)
          Returns the index of the display item with the specified value.
 Object getViewModel()
          Returns SelectControl.ViewModel.
protected  String preprocessRequestParameter(String parameterValue)
          Preprocesses the request parameter, substituting empty or blank String with null.
protected  void validateNotNull()
          Controls that the value submitted by the user is found in the select items list.
 
Methods inherited from class org.araneaframework.uilib.form.control.StringValueControl
fromRequest, getRawValueType, setMaxLength, setMinLength, setTrimValue, toResponse
 
Methods inherited from class org.araneaframework.uilib.form.control.EmptyStringNullableControl
isRead
 
Methods inherited from class org.araneaframework.uilib.form.control.StringRequestControl
fromRequestParameters, preprocessRequestParameters, toResponseParameters
 
Methods inherited from class org.araneaframework.uilib.form.control.StringArrayRequestControl
addOnChangeEventListener, clearOnChangeEventListeners, convert, init, readFromRequest, setRawValue, validate
 
Methods inherited from class org.araneaframework.uilib.form.control.BaseControl
_getWidget, action, addError, convertAndValidate, getFormElementCtx, getLabel, getRawValue, handleEvent, isDisabled, isMandatory, isValid, setFormElementCtx, update
 
Methods inherited from class org.araneaframework.core.BaseApplicationWidget
_getComposite, _getViewable, addActionListener, addEventListener, addWidget, addWidget, clearActionListeners, clearEventlisteners, clearGlobalEventListener, disableWidget, enableWidget, event, getActionId, getChildEnvironment, getChildren, getChildWidgetEnvironment, getEnvironment, getEventId, getWidget, handleAction, handleUpdate, propagate, putViewData, putViewDataOnce, removeActionListener, removeEventListener, removeViewData, removeWidget, render, setGlobalEventListener
 
Methods inherited from class org.araneaframework.core.BaseWidget
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.Service
_getService
 
Methods inherited from interface org.araneaframework.Component
_getComponent, getEnvironment, getScope, isAlive
 
Methods inherited from interface org.araneaframework.Viewable
_getViewable
 

Field Detail

items

protected List items
A list of DisplayItems.

Constructor Detail

SelectControl

public SelectControl()
Method Detail

addItem

public void addItem(DisplayItem item)
Adds a select-item to the element.

Specified by:
addItem in interface DisplayItemContainer
Parameters:
item - the item to be added.

addItems

public void addItems(Collection items)
Adds a display-items to the element.

Specified by:
addItems in interface DisplayItemContainer
Parameters:
items - Collection<DisplayItem> the items to be added.

addDisplayItems

public void addDisplayItems(Collection beanCollection,
                            String valueName,
                            String labelName)
Deprecated. use addFromBeanCollection(Collection, String, String) instead

Adds the display-items corresponding to the given value and label fields in Value Object.

Parameters:
beanCollection - Collection of beans, may not contain null.
valueName - the name of the Value Object field corresponding to the value of the select item.
labelName - the name of the Value Object field corresponding to the label of the select item.

addFromBeanCollection

public void addFromBeanCollection(Collection beanCollection,
                                  String valueName,
                                  String displayStringName)
Creates DisplayItems corresponding to beans in beanCollection and adds these to this SelectControl.

Parameters:
beanCollection - Collection of beans
valueName - name of bean field that determines DisplayItems value
displayStringName - name of bean field that determines DisplayItems displayString
Since:
1.1

addFromBeanCollection

public void addFromBeanCollection(Collection beanCollection,
                                  String valueName,
                                  org.apache.commons.collections.Transformer displayTransformer)
Creates DisplayItems corresponding to beans in beanCollection and adds these to this SelectControl.

Parameters:
beanCollection - Collection of beans
valueName - name of bean field that determines DisplayItems value
displayTransformer - Transformer producing label (DisplayItems displayString) for a bean
Since:
1.1

addFromBeanCollection

public void addFromBeanCollection(Collection beanCollection,
                                  org.apache.commons.collections.Transformer valueTransformer,
                                  String displayStringName)
Creates DisplayItems corresponding to beans in beanCollection and adds these to this SelectControl.

Parameters:
beanCollection - Collection of beans
valueTransformer - Transformer producing value (DisplayItem.getValue()) from a bean.
displayStringName - name of bean field that determines DisplayItems displayString
Since:
1.1

addFromBeanCollection

public void addFromBeanCollection(Collection beanCollection,
                                  org.apache.commons.collections.Transformer valueTransformer,
                                  org.apache.commons.collections.Transformer displayTransformer)
Creates DisplayItems corresponding to beans in beanCollection and adds these to this SelectControl.

Parameters:
beanCollection - Collection of beans
valueTransformer - Transformer producing value (DisplayItem.getValue()) from a bean.
displayTransformer - Transformer producing label (displayString) from a bean
Since:
1.1

clearItems

public void clearItems()
Clears the list of select-items.

Specified by:
clearItems in interface DisplayItemContainer

getDisplayItems

public List getDisplayItems()
Description copied from interface: DisplayItemContainer
Returns a List <DisplayItem> that this DisplayItemContainer currently helds.

Specified by:
getDisplayItems in interface DisplayItemContainer
Returns:
a list of display-items.

getValueIndex

public int getValueIndex(String value)
Description copied from interface: DisplayItemContainer
Returns the index of the display item with the specified value.

Specified by:
getValueIndex in interface DisplayItemContainer
Parameters:
value - display item value.
Returns:
the index of the display item with the specified value.

getSelectedItem

public DisplayItem getSelectedItem()
Returns DisplayItem corresponding to selected element. Current value by which seleced element is determined is reported by the FormElement to which this SelectControl)belongs. If no FormElement is associated with SelectControl, this method returns null.

Returns:
DisplayItem corresponding to selected element.
Since:
1.0.5

validateNotNull

protected void validateNotNull()
Controls that the value submitted by the user is found in the select items list.

Overrides:
validateNotNull in class StringValueControl

getViewModel

public Object getViewModel()
Returns SelectControl.ViewModel.

Overrides:
getViewModel in class StringValueControl
Returns:
SelectControl.ViewModel.

preprocessRequestParameter

protected String preprocessRequestParameter(String parameterValue)
Description copied from class: EmptyStringNullableControl
Preprocesses the request parameter, substituting empty or blank String with null.

Overrides:
preprocessRequestParameter in class EmptyStringNullableControl