Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-3853

ui:include not working inside c:forEach

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 2.2.0
    • 2.2.1
    • 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)

      { pageList = new ArrayList<String>(); pageList.add("page1.xhtml"); pageList.add("page2.xhtml"); }

      return pageList;
      }
      public void setPageList(List<String> pageList)

      { this.pageList = 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="#

      {myfaces22foreach.pageList}

      " var="page">
      <tr>
      <td>
      <ui:include src="#

      {page}

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

      Attachments

        Activity

          People

            lu4242 Leonardo Uribe
            gmanuel Gonçalo Manuel Cruchinho
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: