Tapestry
  1. Tapestry
  2. TAPESTRY-2546

Any component always outputs the same id attribute, rather than a unique id attribute for each render

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.0.13
    • Fix Version/s: 5.0.15
    • Component/s: Core Components
    • Labels:
      None

      Description

      Hello! I've found a problem in component "Any". If I use "Any" component in different components i get duplicate client id. For example, I have component "Header". And I use "Any" in tml like:
      <div t:type="any" t:mixins="myMixin1">
      some content
      <div>

      And I have a component "Dashboard". It contains "Header" and uses "Any" component like:
      <div t:type="any" t:mixins="myMixin2">
      some content
      <div>
      <div t:type="any" t:mixins="myMixin2">
      some content
      <div>
      <div t:type="any" t:mixins="myMixin2">
      some content
      <div>

      Mixins are like this:

      @InjectContainer
      private ClientElement element;
      ...
      String id=element.getClientId();

      This id is realy inique, but generated Ids for div element in "Any" component are duplicate. I have output html like this:

      <div id="any">
      </div>

      <div id="any">
      </div>
      <div id="any_0">
      </div>
      <div id="any_1">
      </div>

      I've found how "Any" component generated id for div element. And i think the solution is:

      Index: tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Any.java
      ===================================================================
      — tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Any.java (revision 681375)
      +++ tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Any.java (working copy)
      @@ -72,7 +72,7 @@
      if (uniqueId == null)

      { uniqueId = renderSupport.allocateClientId(clientId); - anyElement.forceAttributes("id", clientId); + anyElement.forceAttributes("id", uniqueId); }

      return uniqueId;

      1. Any.java.patch
        0.6 kB
        Aleksey Baranyuk

        Activity

        Hide
        Aleksey Baranyuk added a comment -

        This is patch I have generated by svn

        Show
        Aleksey Baranyuk added a comment - This is patch I have generated by svn

          People

          • Assignee:
            Howard M. Lewis Ship
            Reporter:
            Aleksey Baranyuk
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development