javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-1830

UIData inside UIRepeat generates same client ID for all tables

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.3
    • Fix Version/s: 2.1.12, 2.2.0-m06
    • Component/s: None
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      1,830
    • Status Whiteboard:
      Hide

      size_medium importance_medium

      Show
      size_medium importance_medium

      Description

      When UIData is nested inside UIRepeat, all generated table elements retrieve the
      same client ID. The isNestedWithinUIData() helper method inside getClientId()
      returns false for UIRepeat while it should have returned true.

      XHTML example
      -------------
      <ui:repeat value="#

      {bean.list}

      " var="item">
      <h:panelGroup id="foo" />
      <h:dataTable id="bar" />
      </ui:repeat>

      Actual output
      -------------
      <span id="j_idt6:0:foo"></span><table id="j_idt6:0:bar">
      <tbody><tr><td></td></tr></tbody></table>
      <span id="j_idt6:1:foo"></span><table id="j_idt6:0:bar">
      <tbody><tr><td></td></tr></tbody></table>
      <span id="j_idt6:2:foo"></span><table id="j_idt6:0:bar">
      <tbody><tr><td></td></tr></tbody></table>

      Expected output
      ---------------
      <span id="j_idt6:0:foo"></span><table id="j_idt6:0:bar">
      <tbody><tr><td></td></tr></tbody></table>
      <span id="j_idt6:1:foo"></span><table id="j_idt6:1:bar">
      <tbody><tr><td></td></tr></tbody></table>
      <span id="j_idt6:2:foo"></span><table id="j_idt6:2:bar">
      <tbody><tr><td></td></tr></tbody></table>

        Activity

        Hide
        Balázs Zsoldos added a comment -

        For me the solution is to replace the function isNestedWithinUIData to the following makes the trick:

        private Boolean isNestedWithinIterator() {
        if (isNested == null) {
        UIComponent parent = this;
        while (null != (parent = parent.getParent())) {
        if (parent instanceof UIData || parent instanceof UIRepeat)

        { isNested = Boolean.TRUE; break; }

        }
        if (isNested == null)

        { isNested = Boolean.FALSE; }

        return isNested;
        } else

        { return isNested; }

        }

        I renamed the function (and everywhere where it is called from) to isNestedWithinIterator and I check if the parent is instanceof UIRepeat. All actionListeners started to work well in DataTable (inside an UIRepeat).

        Show
        Balázs Zsoldos added a comment - For me the solution is to replace the function isNestedWithinUIData to the following makes the trick: private Boolean isNestedWithinIterator() { if (isNested == null) { UIComponent parent = this; while (null != (parent = parent.getParent())) { if (parent instanceof UIData || parent instanceof UIRepeat) { isNested = Boolean.TRUE; break; } } if (isNested == null) { isNested = Boolean.FALSE; } return isNested; } else { return isNested; } } I renamed the function (and everywhere where it is called from) to isNestedWithinIterator and I check if the parent is instanceof UIRepeat. All actionListeners started to work well in DataTable (inside an UIRepeat).
        Hide
        Balázs Zsoldos added a comment -

        Attaching the repaired UIData.java file based on javax.faces-2.1.4.jar. I am sorry I do not have time now to create and upload the svn patch.

        Please handle this issue together with JAVASERVERFACES-2253 ASAP as these two makes it really hard to use any iteration component in JSF (and both has a solution since a long time)!

        Show
        Balázs Zsoldos added a comment - Attaching the repaired UIData.java file based on javax.faces-2.1.4.jar. I am sorry I do not have time now to create and upload the svn patch. Please handle this issue together with JAVASERVERFACES-2253 ASAP as these two makes it really hard to use any iteration component in JSF (and both has a solution since a long time)!
        Hide
        Manfred Riem added a comment -

        Fixes UIData to check if it is inside a UIRepeat when creating client ids.

        Show
        Manfred Riem added a comment - Fixes UIData to check if it is inside a UIRepeat when creating client ids.
        Hide
        Manfred Riem added a comment -

        Applied to 2.1 branch,

        svn commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-1830, r=rogerk, Fixes UIData to check if it is inside a UIRepeat when creating client ids."
        Sending jsf-api\src\main\java\javax\faces\component\UIData.java
        Adding test\agnostic\renderKit\basic\src\main\java\com\sun\faces\test\agnostic\renderKit\basic\Issue1830Bean.java
        Adding test\agnostic\renderKit\basic\src\main\webapp\WEB-INF\glassfish-web.xml
        Adding test\agnostic\renderKit\basic\src\main\webapp\issue1830.xhtml
        Adding test\agnostic\renderKit\basic\src\test\java\com\sun\faces\test\agnostic\renderKit\basic\Issue1830IT.java
        Transmitting file data .....
        Committed revision 10411.

        Show
        Manfred Riem added a comment - Applied to 2.1 branch, svn commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-1830 , r=rogerk, Fixes UIData to check if it is inside a UIRepeat when creating client ids." Sending jsf-api\src\main\java\javax\faces\component\UIData.java Adding test\agnostic\renderKit\basic\src\main\java\com\sun\faces\test\agnostic\renderKit\basic\Issue1830Bean.java Adding test\agnostic\renderKit\basic\src\main\webapp\WEB-INF\glassfish-web.xml Adding test\agnostic\renderKit\basic\src\main\webapp\issue1830.xhtml Adding test\agnostic\renderKit\basic\src\test\java\com\sun\faces\test\agnostic\renderKit\basic\Issue1830IT.java Transmitting file data ..... Committed revision 10411.
        Hide
        Manfred Riem added a comment -

        Applied to 2.2 trunk,

        svn commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-1830, r=rogerk, Fixes UIData to check if it is inside a UIRepeat when creating client ids."
        Sending jsf-api\src\main\java\javax\faces\component\UIData.java
        Adding test\agnostic\renderKit\basic\src\main\java\com\sun\faces\test\agnostic\renderKit\basic\Issue1830Bean.java
        Adding test\agnostic\renderKit\basic\src\main\webapp\issue1830.xhtml
        Adding test\agnostic\renderKit\basic\src\test\java\com\sun\faces\test\agnostic\renderKit\basic\Issue1830IT.java
        Transmitting file data ....
        Committed revision 10412.

        Show
        Manfred Riem added a comment - Applied to 2.2 trunk, svn commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-1830 , r=rogerk, Fixes UIData to check if it is inside a UIRepeat when creating client ids." Sending jsf-api\src\main\java\javax\faces\component\UIData.java Adding test\agnostic\renderKit\basic\src\main\java\com\sun\faces\test\agnostic\renderKit\basic\Issue1830Bean.java Adding test\agnostic\renderKit\basic\src\main\webapp\issue1830.xhtml Adding test\agnostic\renderKit\basic\src\test\java\com\sun\faces\test\agnostic\renderKit\basic\Issue1830IT.java Transmitting file data .... Committed revision 10412.

          People

          • Assignee:
            Manfred Riem
            Reporter:
            balusc
          • Votes:
            15 Vote for this issue
            Watchers:
            10 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: