You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by smallufo <sm...@gmail.com> on 2013/05/02 04:57:03 UTC
[wicket 6] Any shortcut to get full url ?
I am trying to get full URL , including host and context path , of a
Page.class + PPS.
In 1.4 , I just use *RequestUtils.toAbsolutePath(urlFor(Page.class ,
newPps).toString() , "")* to get full url , but it seems returning relative
url in wicket 6
I tried these ways :
String url1 = urlFor(Page.class , newPps).toString();
System.out.println("url1 = " + url1); // relative
String url2 = RequestUtils.toAbsolutePath(urlFor(Page.class ,
newPps).toString() , "");
System.out.println("url2 = " + url2); // full in 1.4 , but relative in 6.0
String url3 = getRequestCycle().urlFor(new RenderPageRequestHandler(new
PageProvider(Page.class , newPps))).toString();
System.out.println("url3 = " + url3); // relative
String url4 =
getRequestCycle().getUrlRenderer().renderFullUrl(Url.parse(url3));
System.out.println("url4 = " + url4); // full , the correct one !
It means , if I need to get full url (including host / context-path) , I
have to write :
*String fullUrl =
getRequestCycle().getUrlRenderer().renderFullUrl(Url.parse(getRequestCycle().urlFor(new
RenderPageRequestHandler(new PageProvider(Page.class , newPps)))));*
It is so lengthy and cumbersome . Is there any shortcut for this ?
Thanks!
Re: [wicket 6] Any shortcut to get full url ?
Posted by Paul Bors <pa...@bors.ws>.
See chapter 7 "Under the hood of request processing" and 8 "Wicket Links
and URL generation" of the Wicket User Guide at:
http://wicket.apache.org/learn/books/freeguide.html
~ Thank you,
Paul Bors
On Thu, May 2, 2013 at 12:59 AM, Don Ferguson <do...@gmail.com>wrote:
> I'm using something like the following (in 6.7.0):
>
> String url2 = RequestCycle.get().getUrlRenderer()
> .renderFullUrl( Url.parse(urlFor(Page.class, newPps).toString()));
>
>
>
>
> On Wednesday, May 1, 2013 at 9:26 PM, Bertrand Guay-Paquet wrote:
>
> > Hi,
> >
> > On 01/05/2013 10:57 PM, smallufo wrote:
> > > String url2 = RequestUtils.toAbsolutePath(urlFor(Page.class ,
> > > newPps).toString() , "");
> > > System.out.println("url2 = " + url2); // full in 1.4 , but relative in
> 6.0
> > >
> >
> > The Javadoc says "Calculates absolute path to url relative to another
> > absolute url." so that's expected.
> > > It means , if I need to get full url (including host / context-path) ,
> I
> > > have to write :
> > > *String fullUrl =
> > >
> getRequestCycle().getUrlRenderer().renderFullUrl(Url.parse(getRequestCycle().urlFor(new
> > > RenderPageRequestHandler(new PageProvider(Page.class , newPps)))));*
> > >
> > > It is so lengthy and cumbersome . Is there any shortcut for this ?
> > That's what I use, but I wrapped it in a public static util method
> > somewhere...
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org (mailto:
> users-unsubscribe@wicket.apache.org)
> > For additional commands, e-mail: users-help@wicket.apache.org (mailto:
> users-help@wicket.apache.org)
> >
> >
>
>
>
Re: [wicket 6] Any shortcut to get full url ?
Posted by Don Ferguson <do...@gmail.com>.
I'm using something like the following (in 6.7.0):
String url2 = RequestCycle.get().getUrlRenderer()
.renderFullUrl( Url.parse(urlFor(Page.class, newPps).toString()));
On Wednesday, May 1, 2013 at 9:26 PM, Bertrand Guay-Paquet wrote:
> Hi,
>
> On 01/05/2013 10:57 PM, smallufo wrote:
> > String url2 = RequestUtils.toAbsolutePath(urlFor(Page.class ,
> > newPps).toString() , "");
> > System.out.println("url2 = " + url2); // full in 1.4 , but relative in 6.0
> >
>
> The Javadoc says "Calculates absolute path to url relative to another
> absolute url." so that's expected.
> > It means , if I need to get full url (including host / context-path) , I
> > have to write :
> > *String fullUrl =
> > getRequestCycle().getUrlRenderer().renderFullUrl(Url.parse(getRequestCycle().urlFor(new
> > RenderPageRequestHandler(new PageProvider(Page.class , newPps)))));*
> >
> > It is so lengthy and cumbersome . Is there any shortcut for this ?
> That's what I use, but I wrapped it in a public static util method
> somewhere...
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org (mailto:users-unsubscribe@wicket.apache.org)
> For additional commands, e-mail: users-help@wicket.apache.org (mailto:users-help@wicket.apache.org)
>
>
Re: [wicket 6] Any shortcut to get full url ?
Posted by Bertrand Guay-Paquet <be...@step.polymtl.ca>.
Hi,
On 01/05/2013 10:57 PM, smallufo wrote:
> String url2 = RequestUtils.toAbsolutePath(urlFor(Page.class ,
> newPps).toString() , "");
> System.out.println("url2 = " + url2); // full in 1.4 , but relative in 6.0
The Javadoc says "Calculates absolute path to url relative to another
absolute url." so that's expected.
> It means , if I need to get full url (including host / context-path) , I
> have to write :
> *String fullUrl =
> getRequestCycle().getUrlRenderer().renderFullUrl(Url.parse(getRequestCycle().urlFor(new
> RenderPageRequestHandler(new PageProvider(Page.class , newPps)))));*
>
> It is so lengthy and cumbersome . Is there any shortcut for this ?
That's what I use, but I wrapped it in a public static util method
somewhere...
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org