On Wed, Jul 27, 2011 at 11:59 AM, Christopher Schultz <ch...@christopherschultz.net> wrote: > All, > > I've been trying to switch my templates from using > LinkTool.addIgnore()....addAllParameters() to use > LinkTool.addRequestParamsExcept(String... allButThese) but I'm having a > bit of difficulty with it. > > If I call addRequestParams() with no argument, things work as expect. On > the other hand, this does not work: > > #set($ignoreList = ['foo']) > $link.relative('/bar').addRequestParamsExcept($ignoreList) > > I get an invalid reference log message and the above "$link..." text is > rendered as written instead of evaluating successfully. > > Without much investigation, I believe the problem is that the ignoreList > is a List and it needs to be String[]. Velocity will auto-convert Lists > into Object[] if appropriate, but I suspect that the resulting object > type is Object[] and not, say, String[].
i believe you're right. > There does not appear to be a way to create a String[] from a Velocity > template, so using addRequestParams and the other, similar methods will > be very difficult to use with an argument. why not just do $link.addRequestParamsExcept('foo', 'bar', 'etc')? > If anyone has any suggestions for how to use these methods with > template-supplied data, I'd love to hear them. Otherwise, I'm inclined > to either overload or modify these methods to accept an Object[] > parameter and throw an exception if the array elements are not String > objects. i think that would be a good enhancement regardless. i don't particularly like templates and tools being picky about types when they don't have to be. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org For additional commands, e-mail: user-h...@velocity.apache.org