You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Christian Koller <ch...@net-m.ch> on 2010/09/30 18:02:40 UTC

absolute asset url

Hi all

In a tapestry page i have:

@Inject
@Property
@Path("context:/img/logo.gif")
private Asset logo;

If I print the logo I can see:
/assets/7f46afe50e4fd75d/ctx/img/logo.gif

What I need is an absolute url from the logo (e.g: http://localhost:8080/assets/7f46afe50e4fd75d/ctx/img/logo.gif). Is that possible without to use the request.
I mean is there a better way as to fetch the host and port from the request and then to concatenate the stuff.

Thx
chris



Re: absolute asset url

Posted by Josh Canfield <jo...@gmail.com>.
Have you looked into BaseURLSource?
http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/services/BaseURLSource.html

Overriding it is documented along with https but you can @Inject and
use it elsewhere.
http://tapestry.apache.org/tapestry5/guide/secure.html

Josh

2010/9/30 Christian Koller <ch...@net-m.ch>:
> Hi all
>
> In a tapestry page i have:
>
> @Inject
> @Property
> @Path("context:/img/logo.gif")
> private Asset logo;
>
> If I print the logo I can see:
> /assets/7f46afe50e4fd75d/ctx/img/logo.gif
>
> What I need is an absolute url from the logo (e.g: http://localhost:8080/assets/7f46afe50e4fd75d/ctx/img/logo.gif). Is that possible without to use the request.
> I mean is there a better way as to fetch the host and port from the request and then to concatenate the stuff.
>
> Thx
> chris
>
>
>



-- 
--
http://www.bodylabgym.com - a private, by appointment only, one-on-one
health and fitness facility.
--
http://www.ectransition.com - Quality Electronic Cigarettes at a
reasonable price!
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.

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


Re: absolute asset url

Posted by Christian Köberl <ta...@gmail.com>.
The best thing is to have a setting (e.g. a Symbol) with the server url in
it. Because with some configurations (e.g. with a load balancer in front)
you cannot get the real server url via the HttpRequest. 

So your code would look something like this:

@Inject
@Path("context:/img/logo.gif")
private Asset logo;

@Value("server.url")
private String serverUrl

public String getLogoUrl()
{
    return serverUrl + logo.toClientURL();
}

Cheers,
another Chris

PS: you can also add your own binding prefix "absolute:" but that needs some
more work.
-- 
View this message in context: http://tapestry-users.832.n2.nabble.com/absolute-asset-url-tp5588296p5599216.html
Sent from the Tapestry Users mailing list archive at Nabble.com.

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


absolute asset url

Posted by Christian Koller <Ch...@net-m.ch>.
I have to use an external image scale service and this service needs an absolute url, the service can't work with a relative url.


On 02.10.2010, at 04:33, Jonathan Barker wrote:

> What is your use case?
> 
> I need to have absolute URL's for an application and I contribute an
> override for the AssetPathConstructor.
> 
> 
> 
> 2010/9/30 Christian Koller <ch...@net-m.ch>
> 
>> Hi all
>> 
>> In a tapestry page i have:
>> 
>> @Inject
>> @Property
>> @Path("context:/img/logo.gif")
>> private Asset logo;
>> 
>> If I print the logo I can see:
>> /assets/7f46afe50e4fd75d/ctx/img/logo.gif
>> 
>> What I need is an absolute url from the logo (e.g:
>> http://localhost:8080/assets/7f46afe50e4fd75d/ctx/img/logo.gif). Is that
>> possible without to use the request.
>> I mean is there a better way as to fetch the host and port from the request
>> and then to concatenate the stuff.
>> 
>> Thx
>> chris
>> 
>> 
>> 
> 
> 
> -- 
> Jonathan Barker
> ITStrategic

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


Re: absolute asset url

Posted by Jonathan Barker <jo...@gmail.com>.
What is your use case?

I need to have absolute URL's for an application and I contribute an
override for the AssetPathConstructor.



2010/9/30 Christian Koller <ch...@net-m.ch>

> Hi all
>
> In a tapestry page i have:
>
> @Inject
> @Property
> @Path("context:/img/logo.gif")
> private Asset logo;
>
> If I print the logo I can see:
> /assets/7f46afe50e4fd75d/ctx/img/logo.gif
>
> What I need is an absolute url from the logo (e.g:
> http://localhost:8080/assets/7f46afe50e4fd75d/ctx/img/logo.gif). Is that
> possible without to use the request.
> I mean is there a better way as to fetch the host and port from the request
> and then to concatenate the stuff.
>
> Thx
> chris
>
>
>


-- 
Jonathan Barker
ITStrategic