[
https://issues.apache.org/jira/browse/TOMAHAWK-1522?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jakob Korherr resolved TOMAHAWK-1522.
-------------------------------------
Fix Version/s: 1.1.10-SNAPSHOT
Resolution: Fixed
> Introduce valueType attribute for UISelectMany components
> ---------------------------------------------------------
>
> Key: TOMAHAWK-1522
> URL: https://issues.apache.org/jira/browse/TOMAHAWK-1522
> Project: MyFaces Tomahawk
> Issue Type: Improvement
> Affects Versions: 1.1.9
> Environment: Tomahawk for JSF 2.0
> Reporter: Jakob Korherr
> Assignee: Jakob Korherr
> Fix For: 1.1.10-SNAPSHOT
>
>
> Since JSF 2.0 allows Collections as values of UISelectMany components, it
> introduced the attribute collectionType on every UISelectMany component to
> specify the type of Collection which should be used (e.g. ArrayList). The
> only problem by allowing Collections is that it is not possible in Java to
> get the value type of a type-safe Collection in contrast to arrays where this
> is possible. Thus the System needs a way to get the expected value type in
> order to get the right converter. One way (which is also implemented in
> MyFaces core) is to look at the select items to get a by-type-converter, but
> unfortunately this does not work in some scenarios.
> Thus Tomahawk for JSF 2.0 introduces the valueType attribute for all its
> UISelectMany components (t:selectManyCheckbox, t:selectManyListbox,
> t:selectManyMenu and t:selectManyPicklist) to specify the expected value
> type. The valueType attribute (just like the collectionType attribute) can be
> a String representing a FQCN, a Class or a ValueExpression pointing to a
> String or a Class.
> Example:
> The view:
> <t:selectManyCheckbox value="#{myBean.input}" valueType="java.lang.Float">
> <f:selectItem itemValue="1.2" />
> <f:selectItem itemValue="1.3" />
> <f:selectItem itemValue="1.4" />
> </t:selectManyCheckbox>
> The related getter in the bean myBean:
> public Collection<Float> getInput()
> {
> return input;
> }
> Without the valueType information, the component would create a Collection
> containing the selected values as _Strings_, thus leading to a
> ClassCastException when accessing them. By specifying
> valueType="java.lang.Float", the component knows that the expected value type
> of the Collection is Float and is able to obtain a by-type converter for it.
> Thus the component will create a Collection containing the selected values as
> Floats (actually the expected behavior).
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.