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

updateComponents doesn't peek for client id in For loop

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 4.1.3
    • 4.1.7
    • Framework
    • None
    • any

    Description

      From the mailing list:

      I spent three hours on this silly thing so I hope this post will help you
      avoid that!

      I was testing this out with two iterations of the loop, and that's what
      caused me grief. As soon as I switched to four iterations, I figured out
      what was happening:

      I have a SimplePage.html which includes this:

      < span jwcid="@For" source="ognl:wordList" value="ognl:word"
      index="ognl:objectIndex" >
      < a href="#" jwcid="@DirectLink" updateComponents="componentWrapper"
      listener="listener:showTheWord" parameters="ognl:word">Show the word
      < p>
      < span jwcid="componentWrapper@Any">
      < div jwcid="showWordComponent"/>
      < /span>
      < /p>
      < /span>
      < /span>

      I look at the generated page source and the clientId's within the
      @DirectLink links don't look right:

      < span id="For">
      < a id="DirectLink"
      href="/playing/SimplePage,$DirectLink.direct?sp=Sfirst&updateParts=componentWrapper"
      onclick="return tapestry.linkOnClick(this.href,'DirectLink', false)">Show
      the word
      < p>
      < span id="componentWrapper">
      Word:
      < /span>
      < /p>
      < /span>
      < a id="DirectLink_0"
      href="/playing/SimplePage,$DirectLink.direct?sp=Ssecond&updateParts=componentWrapper"
      onclick="return tapestry.linkOnClick(this.href,'DirectLink_0', false)">Show
      the word
      < p>
      < span id="componentWrapper_0">
      Word:
      < /span>
      < /p>

      Look at the second link... it still shows 'updateParts=componentWrapper'
      when it should be 'updateParts=componentWrapper_0'.

      The solution to this is trivial (once you know what's going on!). Simply
      move the directlink code below the component in question, so we have:

      < span jwcid="@For" source="ognl:wordList" value="ognl:word"
      index="ognl:objectIndex" >
      < p>
      < span jwcid="componentWrapper@Any">
      < div jwcid="showWordComponent"/>
      < /span>
      < /p>
      < a href="#" jwcid="@DirectLink" updateComponents="componentWrapper"
      listener="listener:showTheWord" parameters="ognl:word">Show the word
      < /span>
      < /span>

      Now the links will be correct. The reason this happens is that the
      @DirectLink component will ask for the componentWrapper clientId on the
      first round, and it will default to the componentId because the clientId has
      not been set yet because componentWrapper has not been rendered. The second
      time around, the @DirectLink will still have the wrong value because it
      renders before the componentWrapper.

      I hope all that was clear.... if not, please ask questions and I'll be happy
      to re-write and re-word it.

      Jim

      Attachments

        Activity

          People

            Unassigned Unassigned
            jkuhnert Jesse Kuhnert
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: