Hi Ilya,

IMHO I don't think this should be a Tapestry function, constructing an absolute 
URL is not always perfectly generic... i.e.: detecting SSL, port and hostname 
reliably to construct the URL from. Sometimes people configure SSL on 
non-standard ports, and browser headers are at best inconsistent. Since the 
servlet API provides what you need, (and only requires you to write a small 
block of code), it should suffice. But what I am getting at is that this code 
tends to be tied to your applications runtime environment.

Kind regards,
Peter


----- Original Message -----
From: "Ilya Obshadko" <ilya.obsha...@gmail.com>
To: "Tapestry users" <users@tapestry.apache.org>
Sent: Tuesday, 15 December, 2009 20:42:36 GMT +02:00 Athens, Beirut, Bucharest, 
Istanbul
Subject: Re: API for obtaining absolute URL of the page?

Probably you've misunderstood my question.

My goal was not to create absolute URI (which is absolute only within a
single website), but full external URL that may appear, for example, in RSS
feed or mail notification.

toAbsoluteURI () method creates exactly what it says:

"Converts the link to an absolute URI, a complete path, starting with a
leading slash."

On Mon, Dec 14, 2009 at 10:15 AM, Kristian Marinkovic <
kristian.marinko...@porsche.co.at> wrote:

> hi
>
> just inject the LinkSource service and create a Link
> object which can generate the absolute URL of a page:
>
> @Inject
> private LinkSource linkSource;
>
> @Inject
> private ComponentResources resources;
>
> public void create() {
>    String absolute =
> linkSource.createPageRenderLink(resources.getPageName(),
> false).toAbsoluteURI();
> }
>
>
> g,
> kris
>
>
>
> Ilya Obshadko <ilya.obsha...@gmail.com>
> 12.12.2009 13:52
> Bitte antworten an
> "Tapestry users" <users@tapestry.apache.org>
>
>
> An
> Tapestry users <users@tapestry.apache.org>
> Kopie
>
> Thema
> API for obtaining absolute URL of the page?
>
>
>
>
>
>
> Just curious, if there is an API that could create absolute URL of the
> given
> page?
>
> Looking at Link interface, there IS a method createAbsoluteURI(), but it
> creates only URI, not URL meaningful for outside world. Still this kind of
> API would be very useful, for example for RSS feeds, mail notifications
> and
> any other sort of content that is not viewed on the website itself.
>
> I know that it's possible to @Inject HttpServletRequest and obtain all
> necessary data from it, but maybe I'm missing some easier way to do that?
>
> --
> Ilya Obshadko
>
>


-- 
Ilya Obshadko

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

Reply via email to