[ 
https://issues.apache.org/jira/browse/MYFACES-3962?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14389650#comment-14389650
 ] 

Leonardo Uribe commented on MYFACES-3962:
-----------------------------------------

I have notice the issue dissapear if you do something to change id according to 
the row like this:

    <c:forEach var="x" items="#{fn:split('a b c d e', ' ')}">
        <h:outputText id="some-id#{x}" value="#{x}"/>,
    </c:forEach>

The problem with generate new ids here is the state. If you add a value in the 
middle of the c:forEach items, the state will not be correctly assigned to the 
row, because since start there is no association between the element and the 
state.

Enforce the syntax to add something else to the id is preferred, because the 
state and the ids are consistent. There is also a performance problem, because 
to generate new ids, if they are duplicated requires check the duplicate for 
every component id, and that kind of calculation does not scale well. It 
degrades the algorithm from linear to exponential, not to mention the other 
nasty issues related to the state.

There is also the consideration for tags like f:ajax, which points to the id of 
a component. If you generate an id in that part, f:ajax stops working, because 
the right component will not be found.

I personally prefer a duplicate id exception, because there is a workaround 
that is just trivial and it is compatible with both implementations. I'll close 
this issue as won't fix. Thanks for the report.

> Duplicate ID exception thrown while iterating with c:forEach
> ------------------------------------------------------------
>
>                 Key: MYFACES-3962
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3962
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: General
>    Affects Versions: 2.2.7
>            Reporter: Mircea Toma
>         Attachments: test.war
>
>
> A duplicate ID exception is thrown when iterating over a collection/array 
> with c:forEach. The exception occurs only when the enclosed components have 
> an ID assigned.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to