Uploaded image for project: 'Tapestry'
  1. Tapestry
  2. TAPESTRY-2546

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

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 5.0.13
    • 5.0.15
    • Core Components
    • 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;

      Attachments

        1. Any.java.patch
          0.6 kB
          Aleksey Baranyuk

        Activity

          People

            hlship Howard Lewis Ship
            alekseybaranyuk Aleksey Baranyuk
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment