velocity-user mailing list archives

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

On 7/27/2011 10:58 AM, chris@christopherschultz.net 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()];
            return
(LinkTool)addRequestParamsExcept(parametersToIgnore.toArray(ignoreThese));
        }
        else if (autoIgnore)
        {
            return (LinkTool)addMissingRequestParams();
        }
        else
        {
            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.

-chris


Mime
View raw message