[richfaces-issues] [JBoss JIRA] (RF-12230) [CDK] c:foreach in a cast component will result on a List<Object> instead of List<UIComponent>

Paul Dijou (JIRA) jira-events at lists.jboss.org
Thu May 3 14:09:17 EDT 2012


Paul Dijou created RF-12230:
-------------------------------

             Summary: [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


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

        


More information about the richfaces-issues mailing list