Unable to add UIComponent to a parent's children
------------------------------------------------

                 Key: TRINIDAD-701
                 URL: https://issues.apache.org/jira/browse/TRINIDAD-701
             Project: MyFaces Trinidad
          Issue Type: Bug
          Components: Components
    Affects Versions: 1.0.1-incubating-core-SNAPSHOT
         Environment: Oracle JDev Development Builds
            Reporter: Rogue


UIComponent#getChildren() states:

"Return a mutable List representing the child UIComponents associated with this 
component."

So, during the encode begin of my component if I decide to add a peer component 
(to my parent's children), and I get a 

java.util.ConcurrentModificationException
        at 
java.util.AbstractList$Itr.checkForComodification(AbstractList.java:449)
        at java.util.AbstractList$Itr.next(AbstractList.java:420)
        at 
org.apache.myfaces.trinidad.render.CoreRenderer.encodeAllChildren(CoreRenderer.java:312)


This is occuring because the CoreRenderer is making use of the new for-each 
syntax:

    for(UIComponent child : (List<UIComponent>)component.getChildren()) 
    {
      if (child.isRendered())
      {
        encodeChild(context, child);
      }
    }


, which internally creates an Iterator. The last few lines on this page 
(http://java.sun.com/j2se/1.5.0/docs/guide/language/foreach.html) highlights 
the the same point and also discusses cases where this ease-of-use is going to 
fail:

... Therefore, the for-each loop is not usable for filtering. Similarly it is 
not usable for loops where you need to replace elements in a list or array as 
you traverse it. Finally, it is not usable for loops that must iterate over 
multiple collections in parallel. These shortcomings were known by the 
designers, ...

Now, if we can change the looping from the for-each syntax to the traditional 
syntax then we will not see this issue.

This is a blocking issue for us. A solution on this would be greatly 
appreciated.

thanks.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to