velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nathan Bubna <>
Subject Re: [tools] StrutsLinkTool's setForward method has different behavior
Date Wed, 27 Jul 2011 14:55:43 GMT
On Wed, Jul 27, 2011 at 7:32 AM,  <> wrote:
>> Basically, setForward
>> passes the url to absolute(url) which would correctly handle absolute
>> urls with query strings but treats relative urls as merely paths,
>> without parsing out anchors or query strings.
> Okay, I'll take a look at this.
>> I think we should adapt both $link.relative($url) and
>> $link.absolute($url) to accept paths with query strings and anchors.
> That would be great. I dunno about anchors, but query strings used to work
> -- at least with SLT's setForward().

anchors should be allowed too.

>> This probably will require a setFromURI(url, withoutOverriding)
>> adapted from what absolute($url) does for actual absolute URIs.
> So "withoutOverriding" really means "don't escape"?

no, it means that after you turn the url into a (which
does the parsing for you) and you are copying out the sections of the
URI into the current LinkTool instance, you don't want to override
things in the currents LinkTool that are absent in the URI.  If the
URI has no scheme, don't set the LinkTool to have a null scheme, and
so on.

>> In the meantime, try this:
>> context.put(, "url");
>> $url.decode($link.setForward('some-reference'))
> That's not going to work because we also add more query string data to the
> link after the setForward() call. (I simplified my original example).

As long as your query string data doesn't have anything encoded that
you don't want decoded, then add the params before decoding and don't
worry about it.

> LinkTool would be most flexible if it would parse any existing query string
> into it's own parameter table OR be sensitive about an existing query string
> and add anything to is as appropriate (this would probably be best, unless
> there are methods in LinkTool that expect to be able to /replace/
> previously-set query string parameters).

The method of upgrading relative(url) and absolute(url) that i
describe above will parse and add params to the internal map, because
yes, there are methods that expect to be able to replace parameters.

>> Or extend StrutsLinkTool to do that for you.
> I think I'll try to hack SLT to work for me temporarily with an eye towards
> a longer-term solution that actually gets committed to VELTOOLS. I need to
> get this working so I can continue to use VELTOOLS-2.0... otherwise I'll
> have to roll-back to 1.4.

Please don't. :)

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message