Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
2.2.0
-
None
-
None
Description
Using ui:include inside a c:forEach cases a duplicate id error. This only happens if there is at least a second element to iterate.
The exception is the following: java.lang.IllegalStateException: Client-id : <clientId> is duplicated in the faces tree.
Below there's an example of a test case that replicates the problem.
Test Case
Myfaces22ForEach.java
@ManagedBean(name = "myfaces22foreach")
@SessionScoped
public class Myfaces22ForEach {
private List<String> pageList;
public List<String> getPageList() {
if (pageList == null)
return pageList;
}
public void setPageList(List<String> pageList)
}
myfaces22foreach.xhtml
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<title>Myfaces 2.2 | forEach Test</title>
</h:head>
<h:body>
<h:form>
<table>
<c:forEach items="#
" var="page">
<tr>
<td>
<ui:include src="#
" />
</td>
</tr>
</c:forEach>
</table>
</h:form>
</h:body>
</html>
page1.xhtml
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:outputText value="Page1" />
</ui:composition>
page2.xhtml
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:outputText value="Page2" />
</ui:composition>