[richfaces-issues] [JBoss JIRA] (RF-12296) Improve CDK c:forEach typing
Lukáš Fryč (JIRA)
jira-events at lists.jboss.org
Wed Aug 22 06:29:15 EDT 2012
[ https://issues.jboss.org/browse/RF-12296?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12712959#comment-12712959 ]
Lukáš Fryč commented on RF-12296:
---------------------------------
Paul, I believe this issue is caused by no type information about {{MyEnum}} expression, rather than {{c:forEach}}.
CDK holds type information about each expression specifically, say {{item}}. But {{MyEnum}} expression is considered to be {{Object}} by CDK, thus {{item}} is {{Object}} (this is fallback solution of CDK when it can't detect type of expression given by {{items}} attribute).
I think this could be solve by CDK pre-processing of static imports, at this case, {{MyEnum}} expression should be determined to be {{Enum}}.
----
I believe we should come with comprehensive support for using statically imported classes and methods:
e.g. {{import static java.text.MessageFormat.format}} will allow me to use following expression: {{format(...)}}
or {{import static MyRenderKitUtils}} will allow me to use {{MyRenderKitUtils.list}} with correct typing.
> Improve CDK c:forEach typing
> ----------------------------
>
> Key: RF-12296
> URL: https://issues.jboss.org/browse/RF-12296
> Project: RichFaces
> Issue Type: Feature Request
> Security Level: Public(Everyone can see)
> Components: cdk
> Affects Versions: 4.2.2.Final
> Environment: All
> Reporter: Paul Dijou
> Labels: cdk, richfaces, type
> Fix For: 4.3.0.Milestone2
>
>
> As we can see on [this comment|https://issues.jboss.org/browse/RF-10037?focusedCommentId=12696717&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12696717], you currently need to assign a list/array to a var before using it inside a {{<c:forEach>}} or the CDK doesn't know its correct type.
> As suggested by Lukas, I agree to add a {{cdk:itemType}} (or {{cdk:type}} like in the {{<cdk:object>}} tag) to specify manually the type of the object inside the iteration. If this attribute is present in the {{<c:forEach>}}, then the CDK use it to cast the object, otherwise it does the same as currently, no regression.
> In addition, for Enum, I would also try to use the initial import :
> {code:xml}
> <cdk:import package="org.richfaces.component" names="MyEnum" />
> {code}
> In order to know the type of each Enum and then be able to correctly cast the following code :
> {code:xml}
> <cc:implementation>
> <c:forEach items="#{MyEnum.values()}" var="item">
> #{item}
> </c:forEach>
> </cc:implementation>
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the richfaces-issues
mailing list