[
https://issues.apache.org/jira/browse/MYFACES-1834?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12605485#action_12605485
]
Leonardo Uribe commented on MYFACES-1834:
-----------------------------------------
The problem is the lack of documentation about how should interact jsf
components with non jsp components like jstl or jsp.
To start solving this we need a clear objective about how ids should be
generated.
One proposed behavior of how this should behave is this:
If we have a code like this (with id set):
<c:forEach var="item" items="#{listBean.stringList}">
<h:inputText id="myId" value="#{item}" />
<br>
<h:inputText id="myId1" value="#{item}" />
<br>
</c:forEach>
This should be the result :
<input id="form:myId" name="form:myId" type="text"
value="A" />
<br>
<input id="form:myId1" name="form:myId1" type="text"
value="A" />
<br>
<input id="form:myIdj_id_1" name="form:myIdj_id_1"
type="text" value="B" />
<br>
<input id="form:myId1j_id_1" name="form:myId1j_id_1"
type="text" value="B" />
<br>
<input id="form:myIdj_id_2" name="form:myIdj_id_2"
type="text" value="C" />
<br>
<input id="form:myId1j_id_2" name="form:myId1j_id_2"
type="text" value="C" />
<br>
<input id="form:myIdj_id_3" name="form:myIdj_id_3"
type="text" value="D" />
<br>
<input id="form:myId1j_id_3" name="form:myId1j_id_3"
type="text" value="D" />
<br>
With generated id:
<c:forEach var="item" items="#{listBean.stringArray}">
<h:inputText value="#{item}" />
<h:inputText value="#{item}" />
<br>
</c:forEach>
The result:
<input id="form:j_id_id37" name="form:j_id_id37"
type="text" value="A" />
<input id="form:j_id_id38" name="form:j_id_id38"
type="text" value="A" />
<br>
<input id="form:j_id_id37j_id_1"
name="form:j_id_id37j_id_1" type="text" value="B" />
<input id="form:j_id_id38j_id_1"
name="form:j_id_id38j_id_1" type="text" value="B" />
<br>
<input id="form:j_id_id37j_id_2"
name="form:j_id_id37j_id_2" type="text" value="C" />
<input id="form:j_id_id38j_id_2"
name="form:j_id_id38j_id_2" type="text" value="C" />
<br>
<input id="form:j_id_id37j_id_3"
name="form:j_id_id37j_id_3" type="text" value="D" />
<input id="form:j_id_id38j_id_3"
name="form:j_id_id38j_id_3" type="text" value="D" />
Actually, the generated id is skipped by one (from 37 jumps to 39). First we
need a correction of this unwanted behavior.
When there is a inclusion (jsp:include or things like that):
<h:panelGrid columns="2">
<jsp:include page="/comp.jsp"/>
<jsp:include page="/comp2.jsp"/>
<jsp:include page="/comp.jsp"/>
<jsp:include page="/comp2.jsp"/>
<jsp:include page="/comp.jsp"/>
<jsp:include page="/comp2.jsp"/>
</h:panelGrid>
comp.jsp
<h:inputText id="myId" value="HELLO WITH ID SET" />
<h:inputText value="HELLO GEN ID" />
comp2.jsp
<h:inputText id="otherId" value="HELLO WITH ID SET" />
<h:inputText value="HELLO GEN ID" />
This should be the result:
<table>
<tbody>
<tr>
<td><input id="form:myId" name="form:myId" type="text" value="HELLO WITH ID
SET" /></td>
<td><input id="form:j_id_id9" name="form:j_id_id9" type="text" value="HELLO
GEN ID" /></td></tr>
<tr>
<td><input id="form:otherId" name="form:otherId" type="text" value="HELLO
WITH ID SET" /></td>
<td><input id="form:j_id_id10" name="form:j_id_id10" type="text" value="HELLO
GEN ID" /></td>
</tr>
<tr>
<td><input id="form:myIdj_id_1" name="form:myIdj_id_1" type="text"
value="HELLO WITH ID SET" /></td>
<td><input id="form:j_id_id9j_id_1" name="form:j_id_id9j_id_1" type="text"
value="HELLO GEN ID" /></td>
</tr>
<tr>
<td><input id="form:otherIdj_id_1" name="form:otherIdj_id_1" type="text"
value="HELLO WITH ID SET" /></td>
<td><input id="form:j_id_id10j_id_1" name="form:j_id_id10j_id_1" type="text"
value="HELLO GEN ID" /></td>
</tr>
<tr>
<td><input id="form:myIdj_id_2" name="form:myIdj_id_2" type="text"
value="HELLO WITH ID SET" /></td>
<td><input id="form:j_id_id9j_id_2" name="form:j_id_id9j_id_2" type="text"
value="HELLO GEN ID" /></td>
</tr>
<tr>
<td><input id="form:otherIdj_id_2" name="form:otherIdj_id_2" type="text"
value="HELLO WITH ID SET" /></td>
<td><input id="form:j_id_id10j_id_2" name="form:j_id_id10j_id_2" type="text"
value="HELLO GEN ID" /></td>
</tr>
</tbody>
</table>
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.