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 "jakarta.faces.Listbox". This value
can be changed by calling the setRendererType() method.
The jakarta.faces.render.Renderer for this component must perform the following logic on
getConvertedValue():
Obtain the
jakarta.faces.convert.Converterusing the following algorithm:If the component has an attached
jakarta.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-classjakarta.faces.convert.Converterfor this primitive type.An array of objects (such as
Integer[]orString[]). Look up the registered by-classjakarta.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 jakarta.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 jakarta.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 jakarta. The standard component family for this component. |
| public static final String | COMPONENT_TYPE
Hides jakarta. The standard component type for this component. |
| public static final String | INVALID_MESSAGE_ID
The message identifier of the |
| private transient Object |
| 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 jakarta.
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 occurrences of a particular element in the array. |
| public String | getFamily()
Overrides jakarta. 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 Object | getSubmittedValue()
Overrides jakarta. Implements jakarta.
Return the submittedValue value of this |
| public ValueExpression | Returns: the value expression, ornull.Name of the attribute or property for which to retrieve a name)ValueExpressionOverrides jakarta.
Return any |
| private Iterator | |
| public void | setSelectedValues(Object[]
The new selected values (if any) selectedValues)
Set the currently selected values, or |
| public void | setSubmittedValue(Object
The new submitted value submittedValue)Overrides jakarta. Implements jakarta.
Set the submittedValue value of this |
| public void | setValueExpression(String
Name of the attribute or property for which to set a name, ValueExpression binding)ValueExpressionOverrides jakarta.
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 jakarta.
In addition to the standard validation behavior inherited from
|
| COMPONENT_FAMILY | back to summary |
|---|---|
| public static final String COMPONENT_FAMILY Hides jakarta. The standard component family for this component. | |
| COMPONENT_TYPE | back to summary |
|---|---|
| public static final String COMPONENT_TYPE Hides jakarta. 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 | |
| submittedValue | back to summary |
|---|---|
| private transient Object submittedValue | |
| UISelectMany | back to summary |
|---|---|
| public UISelectMany()
Create a new | |
| compareValues | back to summary |
|---|---|
| protected boolean compareValues(Object previous, Object value) Overrides jakarta.
Return | |
| countElementOccurrence | back to summary |
|---|---|
| private static int countElementOccurrence(Object element, Object[] array) Return the number of occurrences of a particular element in the array. | |
| getFamily | back to summary |
|---|---|
| public String getFamily() Overrides jakarta. Doc from jakarta.
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
| |
| getSubmittedValue | back to summary |
|---|---|
| public Object getSubmittedValue() Overrides jakarta. Implements jakarta. Doc from jakarta.
Return the submittedValue value of this
| |
| getValueExpression | back to summary |
|---|---|
| public ValueExpression getValueExpression(String name) Overrides jakarta.
Return any
| |
| getValuesIterator | back to summary |
|---|---|
| private Iterator | |
| setSelectedValues | back to summary |
|---|---|
| public void setSelectedValues(Object[] selectedValues)
Set the currently selected values, or
| |
| setSubmittedValue | back to summary |
|---|---|
| public void setSubmittedValue(Object submittedValue) Overrides jakarta. Implements jakarta. Doc from jakarta.
Set the submittedValue value of this | |
| setValueExpression | back to summary |
|---|---|
| public void setValueExpression(String name, ValueExpression binding) Overrides jakarta.
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 jakarta.
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
| |