org.araneaframework.uilib.form.control
Class SelectControl

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.control.BaseControl
                      extended by org.araneaframework.uilib.form.control.StringArrayRequestControl
                          extended by org.araneaframework.uilib.form.control.StringRequestControl
                              extended by org.araneaframework.uilib.form.control.EmptyStringNullableControl
                                  extended by org.araneaframework.uilib.form.control.StringValueControl
                                      extended by org.araneaframework.uilib.form.control.SelectControl
All Implemented Interfaces:
Serializable, Component, Composite, Composite.CompositeComponent, Composite.CompositeService, Composite.CompositeWidget, ApplicationComponent, ApplicationService, ApplicationWidget, Service, Control, FormElementAware, DisplayItemContainer, 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/interfaces inherited from class org.araneaframework.uilib.form.control.BaseControl
BaseControl.WidgetImpl
 
Nested classes/interfaces inherited from class org.araneaframework.core.BaseApplicationWidget
BaseApplicationWidget.CompositeImpl, BaseApplicationWidget.ViewableImpl
 
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.Widget
Widget.Interface
 
Nested classes/interfaces inherited from interface org.araneaframework.Viewable
Viewable.Interface, Viewable.ViewableComponent, Viewable.ViewableService, Viewable.ViewableWidget
 
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
 
Field Summary
protected  List items
          A list of DisplayItems.
protected  boolean valuesUnique
           
 
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()
           
SelectControl(boolean valuesUnique)
          Creates a SelectControl and provides a way to change whether the values must be unique or not (be default, they must be unique).
 
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.
 void sort(Comparator comparator)
          Provides a way to sort the items in this SelectControl.
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.


valuesUnique

protected boolean valuesUnique
Constructor Detail

SelectControl

public SelectControl()

SelectControl

public SelectControl(boolean valuesUnique)
Creates a SelectControl and provides a way to change whether the values must be unique or not (be default, they must be unique).

Parameters:
valuesUnique - Whether select items must be unique (default: true).
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

sort

public void sort(Comparator comparator)
Provides a way to sort the items in this SelectControl. The comparator parameter is used to compare DisplayItems and, therefore, to set the order.

Parameters:
comparator - Any Comparator that is used to define order of display items.
Since:
1.2

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
See Also:
StringArrayRequestControl.preprocessRequestParameters(String[])