Uploaded image for project: 'Velocity Tools'
  1. Velocity Tools
  2. VELTOOLS-148

LinkTool.addAllParameters causes "ignored" parameters to pollute parent link objects

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0
    • 2.0.x, 3.0
    • VelocityView
    • None
    • Velocity 1.7, Velocity-Tools 2.0

    Description

      The following code will not perform as expected with $link represents an instance of view.tools.LinkTool:

      #set($forward = $link.setRelative('/foo').addQueryData('bar', 'baz'))
      one = $forward.addAllParameters()<br />
      two = $forward.addAllParameters()<br />

      The "addQueryData" appears to be required in order to make this fail.

      The addAllParameters method calls view.LinkTool.addRequestParamsExcept which calls view.LinkTool.addRequestParams which calls generic.LinkTool.duplicate() in order to duplicate the LinkTool before calling view.tools.setParam repeatedly on it.

      generic.LinkTool.duplicate clones the LinkTool object including the view.tools.LinkTool's reference to the "parametersToIgnore" field. The "child" instances of this LinkTool will then have their "ignores" list bleed-into the parent (and also other siblings) and the ultimate effect is that LinkTool objects derived from that common root will be unable to call addAllParameters() because all parameters will have been added to that ignores list after the first invocation.

      The obvious solution seems to be that view.tools.LinkTool needs to override the duplicate(boolean) method in order to clone the ignores list.

      Attachments

        Activity

          People

            Unassigned Unassigned
            chris@christopherschultz.net Christopher Schultz
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: