org.araneaframework.uilib.form.control
Class MultiSelectControl

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.MultiSelectControl
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 MultiSelectControl
extends StringArrayRequestControl
implements DisplayItemContainer

This class represents a multiselect control (aka list).

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

Nested Class Summary
 class MultiSelectControl.ViewModel
          Represents a multiselect control view model.
 
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
          The DisplayItemUtil.
 
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
MultiSelectControl()
           
 
Method Summary
 void addDisplayItems(Collection valueObjects, 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 MultiSelectControl.
 void addFromBeanCollection(Collection beanCollection, String valueName, org.apache.commons.collections.Transformer displayTransformer)
          Creates DisplayItems corresponding to beans in beanCollection and adds these to this MultiSelectControl.
 void addFromBeanCollection(Collection beanCollection, org.apache.commons.collections.Transformer valueTransformer, String displayStringName)
          Creates DisplayItems corresponding to beans in beanCollection and adds these to this MultiSelectControl.
 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 MultiSelectControl.
 void addItem(DisplayItem item)
          Adds a display-item to the element.
 void addItems(Collection items)
          Adds a display-items to the element.
 void clearItems()
          Clears the list of select-items.
protected  String[] convertToStringArray(Collection data)
          Converts the given List<String> to a String[].
protected  Object fromRequestParameters(String[] parameterValues)
          Converts String[] to List<String>.
 List getDisplayItems()
          Returns a List <DisplayItem> that this DisplayItemContainer currently helds.
 String getRawValueType()
          Returns "List<String>".
 int getValueIndex(String value)
          Returns the index of the display item with the specified value.
 Object getViewModel()
          Returns MultiSelectControl.ViewModel.
protected  String[] preprocessRequestParameters(String[] parameterValues)
          Removes all empty strings from the String[] request parameters.
protected  String[] toResponseParameters(Object controlValue)
          Converts List<String> to String[].
protected  void validateNotNull()
          Empty method for overriding.
 
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, isRead, 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
The DisplayItemUtil.

Constructor Detail

MultiSelectControl

public MultiSelectControl()
Method Detail

addItem

public void addItem(DisplayItem item)
Adds a display-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 - the items to be added.

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.

addDisplayItems

public void addDisplayItems(Collection valueObjects,
                            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:
valueObjects - Collection of Value Objects.
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 MultiSelectControl.

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 MultiSelectControl.

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 MultiSelectControl.

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 MultiSelectControl.

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

getRawValueType

public String getRawValueType()
Returns "List<String>".

Specified by:
getRawValueType in interface Control
Returns:
"List<String>".

getViewModel

public Object getViewModel()
Returns MultiSelectControl.ViewModel.

Overrides:
getViewModel in class StringArrayRequestControl
Returns:
MultiSelectControl.ViewModel.

preprocessRequestParameters

protected String[] preprocessRequestParameters(String[] parameterValues)
Removes all empty strings from the String[] request parameters.

Specified by:
preprocessRequestParameters in class StringArrayRequestControl
Parameters:
parameterValues - String[]- the values from request.
Returns:
the preprocessed values from request.

convertToStringArray

protected String[] convertToStringArray(Collection data)
Converts the given List<String> to a String[].

Parameters:
data - List<String>.
Returns:
String[].

validateNotNull

protected void validateNotNull()
Description copied from class: StringArrayRequestControl
Empty method for overriding. Should contain custom validating logic. This method is called only if the control value is not null.

Overrides:
validateNotNull in class StringArrayRequestControl

fromRequestParameters

protected Object fromRequestParameters(String[] parameterValues)
Converts String[] to List<String>.

Specified by:
fromRequestParameters in class StringArrayRequestControl
Parameters:
parameterValues - the request parameters.
Returns:
control value.

toResponseParameters

protected String[] toResponseParameters(Object controlValue)
Converts List<String> to String[].

Specified by:
toResponseParameters in class StringArrayRequestControl
Parameters:
controlValue - the control value.
Returns:
the String[] representation of the control value.