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

                 Key: VELTOOLS-148
                 URL: https://issues.apache.org/jira/browse/VELTOOLS-148
             Project: Velocity Tools
          Issue Type: Bug
          Components: VelocityView
    Affects Versions: 2.0
         Environment: Velocity 1.7, Velocity-Tools 2.0
            Reporter: Christopher Schultz


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.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org
For additional commands, e-mail: dev-h...@velocity.apache.org

Reply via email to