You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Antoine van Wel <an...@gmail.com> on 2009/04/20 21:14:12 UTC
urlFor troubles
One issue I keep running into when programming with Wicket is using
"urlFor"... I guess I am missing something.
Now I am trying to redirect to a page;
/hello is mounted to HelloPage using an indexed mounting strategy
/user is mounted to UserPage
when a user types /hello/username, HelloPage captures this and should
redirect to /user ; for that I am using
throw new RedirectToUrlException(urlFor(UserPage.class, params).toString());
However, urlFor will generate "../user/username" instead of /user/username
which will result in a wrong URL in a browser.
Using RequestUtils.toAbsolutePath ( .. ) on it will break my unit test,
since it doesn't like the full path including http://... in combination with
the RedirectToUrlException. (It won't find the UserPage class).
Any thoughts what's the best way to tackle this? Now I just strip off all
the "../" which is being output by urlFor, but that really feels like a
dirty hack.
Using 1.3.5
- Antoine
PS the common setResponsePage or throw RestartResponseException won't do in
this case, since I want the URL in the browser to be displaying
/user/username
--
--8<--8<--
take your photos everywhere you go - http://www.memolio.com
--8<--8<--
We don't see things as they are, we see things as we are. - Anais Nin
Whether you think you can or whether you think you can't, you're right. -
Henry Ford
--8<--8<--
Re: urlFor troubles
Posted by Antoine van Wel <an...@gmail.com>.
Nope, didn't. Great, I didn't know that one, really simple. Saves me from
using the urlFor this time, thanks!
If there's a way to use urlFor in this case without the "hacky" approach,
I'm still interested to know.
Antoine
On Mon, Apr 20, 2009 at 9:20 PM, Jeremy Thomerson <jeremy@wickettraining.com
> wrote:
> Have you tried setResponsePage after calling setRedirect(true)?
>
> --
> Jeremy Thomerson
> http://www.wickettraining.com
>
>
>
> On Mon, Apr 20, 2009 at 2:14 PM, Antoine van Wel
> <an...@gmail.com>wrote:
>
> > One issue I keep running into when programming with Wicket is using
> > "urlFor"... I guess I am missing something.
> >
> > Now I am trying to redirect to a page;
> >
> > /hello is mounted to HelloPage using an indexed mounting strategy
> > /user is mounted to UserPage
> >
> > when a user types /hello/username, HelloPage captures this and should
> > redirect to /user ; for that I am using
> >
> > throw new RedirectToUrlException(urlFor(UserPage.class,
> > params).toString());
> >
> >
> > However, urlFor will generate "../user/username" instead of
> /user/username
> > which will result in a wrong URL in a browser.
> >
> > Using RequestUtils.toAbsolutePath ( .. ) on it will break my unit test,
> > since it doesn't like the full path including http://... in combination
> > with
> > the RedirectToUrlException. (It won't find the UserPage class).
> >
> > Any thoughts what's the best way to tackle this? Now I just strip off all
> > the "../" which is being output by urlFor, but that really feels like a
> > dirty hack.
> >
> >
> > Using 1.3.5
> >
> >
> > - Antoine
> >
> >
> > PS the common setResponsePage or throw RestartResponseException won't do
> in
> > this case, since I want the URL in the browser to be displaying
> > /user/username
> >
> >
> > --
> >
> > --8<--8<--
> > take your photos everywhere you go - http://www.memolio.com
> > --8<--8<--
> > We don't see things as they are, we see things as we are. - Anais Nin
> > Whether you think you can or whether you think you can't, you're right. -
> > Henry Ford
> > --8<--8<--
> >
>
--
--8<--8<--
take your photos everywhere you go - http://www.memolio.com
--8<--8<--
We don't see things as they are, we see things as we are. - Anais Nin
Whether you think you can or whether you think you can't, you're right. -
Henry Ford
--8<--8<--
Re: urlFor troubles
Posted by Jeremy Thomerson <je...@wickettraining.com>.
Have you tried setResponsePage after calling setRedirect(true)?
--
Jeremy Thomerson
http://www.wickettraining.com
On Mon, Apr 20, 2009 at 2:14 PM, Antoine van Wel
<an...@gmail.com>wrote:
> One issue I keep running into when programming with Wicket is using
> "urlFor"... I guess I am missing something.
>
> Now I am trying to redirect to a page;
>
> /hello is mounted to HelloPage using an indexed mounting strategy
> /user is mounted to UserPage
>
> when a user types /hello/username, HelloPage captures this and should
> redirect to /user ; for that I am using
>
> throw new RedirectToUrlException(urlFor(UserPage.class,
> params).toString());
>
>
> However, urlFor will generate "../user/username" instead of /user/username
> which will result in a wrong URL in a browser.
>
> Using RequestUtils.toAbsolutePath ( .. ) on it will break my unit test,
> since it doesn't like the full path including http://... in combination
> with
> the RedirectToUrlException. (It won't find the UserPage class).
>
> Any thoughts what's the best way to tackle this? Now I just strip off all
> the "../" which is being output by urlFor, but that really feels like a
> dirty hack.
>
>
> Using 1.3.5
>
>
> - Antoine
>
>
> PS the common setResponsePage or throw RestartResponseException won't do in
> this case, since I want the URL in the browser to be displaying
> /user/username
>
>
> --
>
> --8<--8<--
> take your photos everywhere you go - http://www.memolio.com
> --8<--8<--
> We don't see things as they are, we see things as we are. - Anais Nin
> Whether you think you can or whether you think you can't, you're right. -
> Henry Ford
> --8<--8<--
>