Re: Best way to get the base application URL?

2013-04-03 Thread Andrea Del Bene

Thank you Dan! Your code works perfectly!

Url relative = Url.parse(getRequest().getContextPath());
String full = getRequestCycle().getUrlRenderer().renderFullUrl(relative);



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Best way to get the base application URL?

2013-04-03 Thread Dan Retzlaff
How about:

Url relative = Url.parse(getRequest().getContextPath());
String full = getRequestCycle().getUrlRenderer().renderFullUrl(relative);

Dan


On Wed, Apr 3, 2013 at 5:44 AM, Andrea Del Bene wrote:

> Hi,
>
> do you know the best way to get the base URL for our Wicket application?
> For example
>
> "http://www.mysite.com/**myapplication
> "
>
> I'm using the following code at the moment:
>
>
> protected CharSequence extractBaseUrl(Request request) {
> Url originalUrl = request.getOriginalUrl();
> CharSequence baseUrl = originalUrl.getProtocol() + "://" +
> originalUrl.getHost() +
> ":" + originalUrl.getPort() +
> request.getContextPath();
>
>
> return baseUrl;
> }
>
> --**--**-
> To unsubscribe, e-mail: 
> users-unsubscribe@wicket.**apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: Best way to get the base application URL?

2013-04-03 Thread Paul Bors
I've used this to show the full URL to one of my pages as the model object
of a hyperlink including the paramaters (since I have a bookmarkable page):

HttpServletRequest httpReq =
(HttpServletRequest)((WebRequest)RequestCycle.get().getRequest()).getContainerRequest();
String relativePagePath = urlFor(DownloadMSIPage.class, params).toString();
String url =
RequestUtils.toAbsolutePath(httpReq.getRequestURL().toString(),
relativePagePath);
~ Thank you,
   Paul Bors
On Wed, Apr 3, 2013 at 8:44 AM, Andrea Del Bene wrote:

> Hi,
>
> do you know the best way to get the base URL for our Wicket application?
> For example
>
> "http://www.mysite.com/**myapplication
> "
>
> I'm using the following code at the moment:
>
>
> protected CharSequence extractBaseUrl(Request request) {
> Url originalUrl = request.getOriginalUrl();
> CharSequence baseUrl = originalUrl.getProtocol() + "://" +
> originalUrl.getHost() +
> ":" + originalUrl.getPort() +
> request.getContextPath();
>
>
> return baseUrl;
> }
>
> --**--**-
> To unsubscribe, e-mail: 
> users-unsubscribe@wicket.**apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Best way to get the base application URL?

2013-04-03 Thread Andrea Del Bene

Hi,

do you know the best way to get the base URL for our Wicket application? 
For example


"http://www.mysite.com/myapplication";

I'm using the following code at the moment:


protected CharSequence extractBaseUrl(Request request) {
Url originalUrl = request.getOriginalUrl();
CharSequence baseUrl = originalUrl.getProtocol() + "://" + 
originalUrl.getHost() +
":" + originalUrl.getPort() + 
request.getContextPath();



return baseUrl;
}

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org