UISelectMany is a
UIComponent that represents the user's choice of a zero or
more items from among a discrete set of available options. The user
can modify the selected values. Optionally, the component can be
preconfigured with zero or more currently selected items, by storing
them as an array or
Collection in the value property of
the component.
This component is generally rendered as a select box or a group of checkboxes.
By default, the rendererType property must be set to
"javax.faces.Listbox". This value can be changed by
calling the setRendererType() method.
The javax.faces.render.Renderer for this component must
perform the following logic on getConvertedValue():
Obtain the
javax.faces.convert.Converterusing the following algorithm:If the component has an attached
javax.faces.convert.Converter, use it.If not, look for a
ValueExpressionforvalue(if any). TheValueExpressionmust point to something that is:
An array of primitives (such as
int[]). Look up the registered by-classjavax.faces.convert.Converterfor this primitive type.An array of objects (such as
Integer[]orString[]). Look up the registered by-classjavax.faces.convert.Converterfor the underlying element type.A
java.util.Collection. Do not convert the values. Instead, convert the provided set of available options to string, exactly as done during render response, and for any match with the submitted values, add the available option as object to the collection.If for any reason a
Convertercannot be found, assume the type to be a String array.
Use the selected javax.faces.convert.Converter (if any) to
convert each element in the values array from the request to the
proper type, and store the result of
each conversion in a data structure, called
targetForConvertedValues for discussion. Create
targetForConvertedValues using the following
algorithm.
If the component has a ValueExpression for
value and the type of the expression is an array, let
targetForConvertedValues be a new array of the expected
type.
If the component has a ValueExpression for
value, let modelType be the type of the value
expression. If modelType is a Collection, do
the following to arrive at targetForConvertedValues:
Ask the component for its attribute under the key
"collectionType", without the quotes. If there is a
value for that key, the value must be a String that is a fully
qualified Java class name, or a Class object, or a
ValueExpression that evaluates to a String or a
Class. In all cases, the value serves to identify the
concrete type of the class that implements Collection.
For discussion, this is called collectionType. Let
targetForConvertedValues be a new instance of
Collection implemented by the concrete class specified
in collectionType. If, collectionType can not be
discovered, or an instance of Collection implemented by
the concrete class specified in collectionType cannot be
created, throw a javax.faces.FacesException with a correctly
localized error message. Note that FacesException is
thrown instead of ConverterException because this case
would only arise from developer error, rather than end-user
error.
If there is no "collectionType" attribute, call
getValue() on the component. The result will implement
Collection. If the result also implements
Cloneable, let targetForConvertedValues be the
result of calling its clone() method, then calling
clear() on the cloned Collection. If
unable to clone the value for any reason, log a message and proceed
to the next step.
If modelType is a concrete class, let
targetForConvertedValues be a new instance of that class.
Otherwise, the concrete type for targetForConvertedValues is
taken from the following table. All classes are in the
java.util package. All collections must be created with
an initial capacity equal to the length of the values array from the
request.
| If modelType is an instance of | then targetForConvertedValues must be an instance of |
|---|---|
SortedSet |
TreeSet |
Queue |
LinkedList |
Set |
HashSet |
| anything else | ArrayList |
If the component does not have a ValueExpression
for value, let targetForConvertedValues be an
array of type Object.
Return targetForConvertedValues after populating it with the converted values.
| Modifier and Type | Class and Description |
|---|---|
| private static class | UISelectMany.ArrayIterator
Exposes an Array as an Iterator. |
| Modifier and Type | Field and Description |
|---|---|
| public static final String | COMPONENT_FAMILY
Hides javax. The standard component family for this component. |
| public static final String | COMPONENT_TYPE
Hides javax. The standard component type for this component. |
| public static final String | INVALID_MESSAGE_ID
The message identifier of the
|
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected boolean | Returns: true if the new value is different from the
previous value, false otherwise.old value of this component previous, Object new value of this component value)Overrides javax. Return |
| private static int | countElementOccurrence(Object
object whose occurrance is to be counted in the array. element, Object[] object representing the old value of this component. array)Return the number of occurrances of a particular element in the array. |
| public String | getFamily()
Overrides javax. Return the identifier of the component family to which this component belongs. |
| public Object[] | Returns: the selected values, ornull.Return the currently selected values, or |
| public ValueBinding | Returns: the value binding, ornullName of the attribute or property for which to retrieve
a name)ValueBindingOverrides javax.
Deprecated
this has been replaced by
getValueExpression(java.lang.String).
Return any |
| public ValueExpression | Returns: the value expression, ornull.Name of the attribute or property for which to retrieve
a name)ValueExpressionOverrides javax. Return any |
| private Iterator | |
| public void | setSelectedValues(Object[]
The new selected values (if any) selectedValues)Set the currently selected values, or |
| public void | setValueBinding(String
Name of the attribute or property for which to set
a name, ValueBinding binding)ValueBindingOverrides javax.
Deprecated
This has been replaced by
setValueExpression(java.lang.String, javax.el.ValueExpression).
Store any |
| public void | setValueExpression(String
Name of the attribute or property for which to set
a name, ValueExpression binding)ValueExpressionOverrides javax. Store any |
| private static Object[] | Returns: an Object array, or null if the incoming value is not in fact an array at all.object containing the primitive values primitiveArray)Convert an array of primitives to an array of boxed objects. |
| protected void | validateValue(FacesContext
The context, Object FacesContext for the current requestThe converted value to test for membership. value)Overrides javax. In addition to the standard
validation behavior inherited from |
| COMPONENT_FAMILY | back to summary |
|---|---|
| public static final String COMPONENT_FAMILY Hides javax. The standard component family for this component. | |
| COMPONENT_TYPE | back to summary |
|---|---|
| public static final String COMPONENT_TYPE Hides javax. The standard component type for this component. | |
| INVALID_MESSAGE_ID | back to summary |
|---|---|
| public static final String INVALID_MESSAGE_ID The message identifier of the
| |
| UISelectMany | back to summary |
|---|---|
| public UISelectMany() Create a new | |
| compareValues | back to summary |
|---|---|
| protected boolean compareValues(Object previous, Object value) Overrides javax. Return | |
| countElementOccurrence | back to summary |
|---|---|
| private static int countElementOccurrence(Object element, Object[] array) Return the number of occurrances of a particular element in the array. | |
| getFamily | back to summary |
|---|---|
| public String getFamily() Overrides javax. Doc from javax. Return the identifier of the component
family to which this component belongs. This identifier, in conjunction
with the value of the | |
| getSelectedValues | back to summary |
|---|---|
| public Object[] getSelectedValues() Return the currently selected values, or
| |
| getValueBinding | back to summary |
|---|---|
| public ValueBinding getValueBinding(String name) Overrides javax. Deprecated this has been replaced by Return any This method relies on the superclass to provide the
| |
| getValueExpression | back to summary |
|---|---|
| public ValueExpression getValueExpression(String name) Overrides javax. Return any
| |
| getValuesIterator | back to summary |
|---|---|
| private Iterator | |
| setSelectedValues | back to summary |
|---|---|
| public void setSelectedValues(Object[] selectedValues) Set the currently selected values, or
| |
| setValueBinding | back to summary |
|---|---|
| public void setValueBinding(String name, ValueBinding binding) Overrides javax. Deprecated This has been replaced by Store any This method relies on the superclass to wrap the argument
| |
| setValueExpression | back to summary |
|---|---|
| public void setValueExpression(String name, ValueExpression binding) Overrides javax. Store any
| |
| toObjectArray | back to summary |
|---|---|
| private static Object[] toObjectArray(Object primitiveArray) Convert an array of primitives to an array of boxed objects. | |
| validateValue | back to summary |
|---|---|
| protected void validateValue(FacesContext context, Object value) Overrides javax. In addition to the standard
validation behavior inherited from This method must explicitly
support a value argument that is a single value or a value
argument that is a If
| |
| Modifier and Type | Field and Description |
|---|---|
| private int | |
| private int | |
| private Object |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public Object | |
| public void | remove()
Overrides default java. |
| idx | back to summary |
|---|---|
| private int idx | |
| length | back to summary |
|---|---|
| private int length | |
| value | back to summary |
|---|---|
| private Object value | |
| ArrayIterator | back to summary |
|---|---|
| pack-priv ArrayIterator(Object value) | |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Doc from java. Returns
| |
| next | back to summary |
|---|---|
| public Object next() Implements java. Doc from java. Returns the next element in the iteration. | |
| remove | back to summary |
|---|---|
| public void remove() Overrides default java. Doc from java. Removes from the underlying collection the last element returned
by this iterator (optional operation). This method can be called
only once per call to The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.
The behavior of an iterator is unspecified if this method is called
after a call to the
| |