Tiles
  1. Tiles
  2. TILES-519

tiles:getAsString is not cleaning tiles context when attribute is not present and ignore=true

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.2
    • Fix Version/s: 2.2.3
    • Component/s: tiles-template
    • Labels:
      None
    • Flags:
      Patch

      Description

      After putting this line in the template:
      <tiles:getAsString name="subtitle" ignore="true"/>
      <tiles:insertAttribute name="body" />

      And if "subtitle" attribute is not defined. The page will fail on rendering the "body" attribute, because getAsString failed to cleanup it's tiles context (endContext() is not executed).

      SOLUTION:
      The problem is in GetAsStringModel class, in the last method - renderAttribute():

      The first three lines that check for null attribute and ignore flag should be inside the try caluse:
      try {
      if (attribute == null && ignore)

      { return; }

      writer.write(...

      This way the finally clause will be executed even in attribute is null and should be ignored. The finally clause is ending the tiles context.

      This is the same as the code inside: InsertAttributeModel.renderAttribute()

      1. TILES-519-tests.patch
        3 kB
        Vitaly Polonetsky
      2. TILES-519-fix.patch
        0.8 kB
        Vitaly Polonetsky

        Activity

        Vitaly Polonetsky created issue -
        Hide
        Antonio Petrelli added a comment -

        Can you attach a patch, as a diff, for this? This way your name will be put in our SVN log for your contributions.

        Thanks.

        Show
        Antonio Petrelli added a comment - Can you attach a patch, as a diff, for this? This way your name will be put in our SVN log for your contributions. Thanks.
        Hide
        Vitaly Polonetsky added a comment -

        No problem, I'll add unit test for it also.

        Show
        Vitaly Polonetsky added a comment - No problem, I'll add unit test for it also.
        Hide
        Antonio Petrelli added a comment -

        Great, thanks!

        Show
        Antonio Petrelli added a comment - Great, thanks!
        Hide
        Vitaly Polonetsky added a comment -

        Added patch that fixes the problem and another patch to add tests (also added small additions to existing tests)

        Show
        Vitaly Polonetsky added a comment - Added patch that fixes the problem and another patch to add tests (also added small additions to existing tests)
        Vitaly Polonetsky made changes -
        Field Original Value New Value
        Attachment TILES-519-fix.patch [ 12468966 ]
        Attachment TILES-519-tests.patch [ 12468967 ]
        Vitaly Polonetsky made changes -
        Flags [Patch]
        Hide
        Antonio Petrelli added a comment -

        The patches seem ok.
        If anyone wants to check and apply them, then do it. Otherwise I think I can apply them this evening or tomorrow.

        Thanks again

        Show
        Antonio Petrelli added a comment - The patches seem ok. If anyone wants to check and apply them, then do it. Otherwise I think I can apply them this evening or tomorrow. Thanks again
        Antonio Petrelli made changes -
        Assignee Antonio Petrelli [ brenmcguire ]
        Hide
        Antonio Petrelli added a comment -

        Applied patch by Vitaly Polonetsky
        Thanks Vitaly!

        Fixed the bug in the sandbox too.

        Show
        Antonio Petrelli added a comment - Applied patch by Vitaly Polonetsky Thanks Vitaly! Fixed the bug in the sandbox too.
        Antonio Petrelli made changes -
        Status Open [ 1 ] Closed [ 6 ]
        Fix Version/s 2.2.3 [ 12315143 ]
        Resolution Fixed [ 1 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Closed Closed
        11h 1m 1 Antonio Petrelli 21/Jan/11 20:47

          People

          • Assignee:
            Antonio Petrelli
            Reporter:
            Vitaly Polonetsky
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development