velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: [tools] LinkTool.addAllParameters is not behaving as before
Date Wed, 27 Jul 2011 20:06:59 GMT

On 7/27/2011 10:58 AM, wrote:
> Here is some good news.
> Although this fails:
> [...]
> This does not fail:
> #set($forward = $link.relative('/foo').param('token', 'xyz'))
>   <p>\$forward=$forward</p>
> PASS  <p>\$forward.addRequestParams()=$forward.addRequestParams()</p>
> So maybe it's a logic error in the implementation of addAllParameters
> specifically, and not the underlying implementation in LinkTool's new code.

I do see /a/ bug in addAllParameters, but it doesn't account for the
problem I'm seeing. Here is the code for addAllParameters:

    public LinkTool addAllParameters()
        if (this.parametersToIgnore != null)
            String[] ignoreThese = new String[parametersToIgnore.size()];
        else if (autoIgnore)
            return (LinkTool)addMissingRequestParams();
            return (LinkTool)addRequestParams();

The "parametersToIgnore" is a List of parameter names that is only
settable via the addIgnore() method in this class.

If you call "addIgnore" /and/ "addQueryData" in the same instance, you
will only get the first branch of the conditional above, and any
"autoIgnore" data will be skipped.

It looks like the "addQueryData" method(s) need to be fixed to respect
the "autoIgnore" flag and add the parameter names to the ignores list.
At that point, the above code will work correctly because the
"parametersToIgnore" list will be updated to include both
explicitly-ignored parameters as well as those implicitly ignored
because they were set using addQueryData with autoIgnore=true (which is
the default with no other configuration).

That doesn't explain why addAllParameters is apparently doing nothing in
my case, but I suspect I'll get to that eventually.


View raw message