You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Ilya Obshadko <il...@gmail.com> on 2009/12/12 13:52:12 UTC

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

Re: API for obtaining absolute URL of the page?

Posted by Peter Stavrinides <P....@albourne.com>.
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" <il...@gmail.com>
To: "Tapestry users" <us...@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.marinkovic@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 <il...@gmail.com>
> 12.12.2009 13:52
> Bitte antworten an
> "Tapestry users" <us...@tapestry.apache.org>
>
>
> An
> Tapestry users <us...@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-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: API for obtaining absolute URL of the page?

Posted by Ilya Obshadko <il...@gmail.com>.
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.marinkovic@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 <il...@gmail.com>
> 12.12.2009 13:52
> Bitte antworten an
> "Tapestry users" <us...@tapestry.apache.org>
>
>
> An
> Tapestry users <us...@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

Re: API for obtaining absolute URL of the page?

Posted by Kristian Marinkovic <kr...@porsche.co.at>.
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 <il...@gmail.com> 
12.12.2009 13:52
Bitte antworten an
"Tapestry users" <us...@tapestry.apache.org>


An
Tapestry users <us...@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