On Tue, 26 Jul 2011 15:08:28 -0700, Nathan Bubna wrote:
> On Tue, Jul 26, 2011 at 2:27 PM, Christopher Schultz
> <chris@...> wrote:
>> We use StrutsLinkTool pretty much everywhere and had been relying on
>> previous behavior (tools 1.4) of StrutsLinkTool.setForward(String)
>> takes a reference to a Struts-defined "forward" which is basically
>> a URL.
>> In the past, we were able to define a URL in Struts like this:
>> <forward name="some-reference" path="/path/to/resource?foo=bar" />
>> Then, in the markup:
>> <a href="$link.setForward('some-reference')">link text</a>
>> It appears that somewhere in the modifications, the URL ha sbeen
>> sanitized and now "/path/to/resource?foo=bar" has been helpfully
>> replaced by "/path/to/resource%3Ffoo=bar".
>> Was this intentional? Is there a way to get the old behavior back?
> It was unintentionally changed, in part because i wasn't aware that
> forwards could/would contain query strings.
Good to know that this wasn't a policy decision. That means it's
possible to get around it :)
> 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().
> 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"?
> In the meantime, try this:
> context.put(java.net.URLDecoder.class, "url");
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
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).
> 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.