org.araneaframework.uilib.form.control
Class SelectControl
java.lang.Object
org.araneaframework.core.BaseComponent
org.araneaframework.core.BaseService
org.araneaframework.core.BaseWidget
org.araneaframework.core.BaseApplicationWidget
org.araneaframework.uilib.form.control.BaseControl
org.araneaframework.uilib.form.control.StringArrayRequestControl
org.araneaframework.uilib.form.control.StringRequestControl
org.araneaframework.uilib.form.control.EmptyStringNullableControl
org.araneaframework.uilib.form.control.StringValueControl
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
|
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.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.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 |
items
protected List items
- A list of
DisplayItems.
valuesUnique
protected boolean valuesUnique
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).
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 beansvalueName - name of bean field that determines DisplayItems valuedisplayStringName - 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 beansvalueName - name of bean field that determines DisplayItems valuedisplayTransformer - 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 beansvalueTransformer - 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 beansvalueTransformer - 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[])