[
https://issues.jboss.org/browse/RF-12230?page=com.atlassian.jira.plugin.s...
]
Lukáš Fryč commented on RF-12230:
---------------------------------
This is also the problem why following warning is shown during build:
{code}
[INFO] --- maven-cdk-plugin:4.3.0-SNAPSHOT:generate (cdk-generate-sources) @
componentName-ui ---
[WARNING] No type found in context for identifier 'prependFacet', handling as
generic Object
{code}
The variable defined by {{<cdk:object />}} wasn't pushed to context of
variables.
[CDK] c:foreach in a cast component will result on a
List<Object> instead of List<UIComponent>
----------------------------------------------------------------------------------------------
Key: RF-12230
URL:
https://issues.jboss.org/browse/RF-12230
Project: RichFaces
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: cdk
Affects Versions: 4.2.1.Final
Environment: All
Reporter: Paul Dijou
Labels: cdk, generated, richfaces, xp
Fix For: 4.3.0.Milestone1
Look at the following code :
{code:xml}
<cdk:object type="javax.faces.component.UIComponent"
name="prependFacet"
value="#{component.getFacet('prepend')}"/>
<c:choose>
<c:when test="#{prependFacet.family eq
'javax.faces.Panel'}">
<c:forEach var="child"
items="#{component.getFacet('prepend').getChildren()}">
{code}
I'm using a {{<cdk:object>}} to assign my facet to a var. Then I make some test
and finally, I want to iterate over the children of my facet. This will result on this
Java code on the renderer :
{code:java}
UIComponent prependFacet = component.getFacet("prepend");
if (isEqual(prependFacet.getFamily(),"javax.faces.Panel")) {
for (UIComponent child: component.getFacet("prepend").getChildren()) {
{code}
That's perfect! But now, since I have a var for my facet, why not using it in the
{{<c:forEach>}}? Seems natural. So I change my code to :
{code:xml}
<cdk:object type="javax.faces.component.UIComponent"
name="prependFacet"
value="#{component.getFacet('prepend')}"/>
<c:choose>
<c:when test="#{prependFacet.family eq
'javax.faces.Panel'}">
<c:forEach var="child"
items="#{prependFacet.getChildren()}">
{code}
Only the last line is different from the previous one. What does the generated Java code
looks like? That:
{code:java}
UIComponent prependFacet = component.getFacet("prepend");
if (isEqual(prependFacet.getFamily(),"javax.faces.Panel")) {
for (Object child: prependFacet.getChildren()) {
{code}
Whaaaaat?! Why is it a "Object" in the "for" loop and not a
"UIComponent" anymore? Of course, the component is now broken since I'm
calling {{UIComponent}} methods inside the loop.
--
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