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

Leonardo Uribe commented on MYFACES-1834:
-----------------------------------------

Checking how jsf ri do this stuff:

1. Mojarra also jumps 2 when generating with c:forEach example. This behavior 
does not have side effects:

                    &nbsp;<input id="form:myId" type="text" name="form:myId" 
value="A" />
                        <br>
                    &nbsp;<input id="form:myId1" type="text" name="form:myId1" 
value="A" />
                        <br>

                
                    &nbsp;<input id="form:myIdj_id_1" type="text" 
name="form:myIdj_id_1" value="B" />
                        <br>
                    &nbsp;<input id="form:myId1j_id_1" type="text" 
name="form:myId1j_id_1" value="B" />
                        <br>
                
                    &nbsp;<input id="form:myIdj_id_2" type="text" 
name="form:myIdj_id_2" value="C" />
                        <br>
                    &nbsp;<input id="form:myId1j_id_2" type="text" 
name="form:myId1j_id_2" value="C" />
                        <br>
                
                    &nbsp;<input id="form:myIdj_id_3" type="text" 
name="form:myIdj_id_3" value="D" />

                        <br>
                    &nbsp;<input id="form:myId1j_id_3" type="text" 
name="form:myId1j_id_3" value="D" />
                        <br>
                
        
                    &nbsp;<input type="text" name="form:j_id_id37" value="A" />
                    &nbsp;<input type="text" name="form:j_id_id39" value="A" />
            <br>
        
                    &nbsp;<input type="text" name="form:j_id_id37j_id_1" 
value="B" />
                    &nbsp;<input type="text" name="form:j_id_id39j_id_1" 
value="B" />
            <br>
        
                    &nbsp;<input type="text" name="form:j_id_id37j_id_2" 
value="C" />
                    &nbsp;<input type="text" name="form:j_id_id39j_id_2" 
value="C" />
            <br>
        
                    &nbsp;<input type="text" name="form:j_id_id37j_id_3" 
value="D" />
                    &nbsp;<input type="text" name="form:j_id_id39j_id_3" 
value="D" />

2. When a jsp:include more than once, throws an duplicated id exception:

javax.servlet.jsp.JspException: Component ID 'myId' has already been used in 
the view.
        at 
javax.faces.webapp.UIComponentClassicTagBase.createId(UIComponentClassicTagBase.java:1591)
        at 
javax.faces.webapp.UIComponentClassicTagBase.findComponent(UIComponentClassicTagBase.java:654)
        at 
javax.faces.webapp.UIComponentClassicTagBase.doStartTag(UIComponentClassicTagBase.java:1142)
        at 
com.sun.faces.taglib.html_basic.InputTextTag.doStartTag(InputTextTag.java:430)

But the strange thing is what happen when is removed myId and otherId component:

<table>
<tbody>
<tr>
<td><input type="text" name="form:j_id_id7pc2" value="HELLO GEN ID" /></td>
<td><input type="text" name="form:j_id_id7pc3" value="HELLO GEN ID" /></td>
</tr>
<tr>
<td><input type="text" name="form:j_id_id7pc4" value="HELLO GEN ID" /></td>
<td><input type="text" name="form:j_id_id7pc5" value="HELLO GEN ID" /></td>

</tr>
<tr>
<td><input type="text" name="form:j_id_id7pc6" value="HELLO GEN ID" /></td>
<td><input type="text" name="form:j_id_id7pc7" value="HELLO GEN ID" /></td>
</tr>
</tbody>
</table>

Another suffix is added!!!. This was tested with mojarra 1.2_08

All this info is with the purpose of people interested can solve this issue.

Suggestions are welcome.

> suffix added to component id when including files
> -------------------------------------------------
>
>                 Key: MYFACES-1834
>                 URL: https://issues.apache.org/jira/browse/MYFACES-1834
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-252
>    Affects Versions: 1.2.2
>            Reporter: Simon Kitching
>            Priority: Minor
>
> In core 1.2 to 1.2.2, any use of jsp:include causes the ids of components in 
> the included file to have a random string appended to them.
> This results in some ugly ids. However more significantly, the id of a 
> component is not predictable even when an id attribute is explicitly assigned.
> In addition, this breaks the tomahawk forceId feature, because although the 
> namespace prefix is omitted the rest of the id changes making "forceId" 
> useless.
> The cause is class UIComponentClassicTagBase, where checkIfItIsInAnIterator() 
> returns true if the current component is in an included or forwarded page. 
> Later, the createUniqueId method adds a suffix to the user-specified if 
> member isInAnIterator is true.
> Unfortunately, documentation on why things are implemented as they are is 
> lacking.
> Checking for iteration is needed to support
>   <c:forEach ..>
>    <h:inputText id="name"/>
>   </c:forEach>
> Checking for includedOrForwarded might be to allow:
>     <jsp:include page="subPage.jsp" />
>     <jsp:include page="subPage.jsp" />
> However this is a very rare usage; support for this should not hurt everyone.
> And Sun Mojarra does *not* mess with the ids like this...testing shows
> that the ids of components are the same regardless of whether they are
> inline or in an included file.
> Maybe the "isInIterator" check could look to see whether the *same file* is 
> being included twice, eg by keeping a list of the files included so far, and 
> returning true only if the same string is encountered twice? That would allow 
> multiple inclusions, but not mess with ids for a single inclusion.

-- 
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