You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by raulmt <ra...@gmail.com> on 2009/01/08 20:29:28 UTC

Tapestry AssetSource

Hi,

I'm trying to obtain the URL of an image (which is in the context, but the
path is obtained from the DB) to pass it to a Flash application. This is the
line i'm using:

String imageURL = assetSource.getAsset(null, sewerGraph.getMapImagePath() ,
threadLocale.getLocale()).toClientURL();

The value of sewerGraph.getMapImagePath() is "context:planos/plano1.png" in
this example, and the result of the line above is "../../planos/plano1.png".
This would be fine if I consider the URL of the page class in which this
line is executed, but the problem is this page has 2 variables of context
that onPassivate puts in the URL (the Page URL transform to
"pageURL/contextVar1/contextVar2). With that, the ../../planos/plano1.png is
relativa to the contextVar2 portion of the URL and then producing a wrong
relative URL.

What am i doing wrong? or is this a problem with context assets in the
AssetSource ?

Regards.

P.S.: if this is not very understandable, please ask me.... i haven't slept
too much lately.... :(
-- 
View this message in context: http://www.nabble.com/Tapestry-AssetSource-tp21359198p21359198.html
Sent from the Tapestry - User 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


Re: Tapestry AssetSource

Posted by raulmt <ra...@gmail.com>.
I understand what is my problem, and it is related to something i didn't
specified here. The line that obtains the clientURL of the Asset in
question, is called in an event triggered from the client side, which has
the URL with two context params. But the URL used to trigger the event
doesn't has these two context params... in fact, it doesn't has any context
params for the event, only one for the page which is specified in the URL
with a GET param ( ?t:ac=3). So, when the event is triggered, the current
request URL is the one of only the page, without any context params.....

When the same line is invoked in a page request with context params, it
works perfectly....

Sorry for this question, I see now that is obvious.... but three nights with
too little sleep affects the brain.. :P

Thanks.


Howard Lewis Ship wrote:
> 
> The relative paths are only relevant when rendering a page.  At that
> time, the base URL of the rendered page is known, it is the current
> request path.  The issue for you is that you are effectively changing
> the base URL on the fly on the client side, and Tapestry isn't
> prepared for that.
> 
> On Thu, Jan 8, 2009 at 12:44 PM, raulmt <ra...@gmail.com> wrote:
>>
>> Thanks Howard. But is it normal that the path optimization doesn't
>> considers
>> the context params of a page then? Are there cases where the context
>> params
>> shouldn't be considered? (I understand that is the problem with the path
>> optimization, doesn't it?).
>>
>>
>> Howard Lewis Ship wrote:
>>>
>>> The Link interface has a method, toAbsoluteURI(), that does what you
>>> want.
>>>
>>> Unfortunately, Asset doesn't have that method.
>>>
>>> One approach would be to override the symbol
>>> SymbolConstants.FORCE_ABSOLUTE_URIS to "true".  This turns off the
>>> request path optimizations that are causing you trouble.
>>>
>>> On Thu, Jan 8, 2009 at 11:29 AM, raulmt <ra...@gmail.com> wrote:
>>>>
>>>> Hi,
>>>>
>>>> I'm trying to obtain the URL of an image (which is in the context, but
>>>> the
>>>> path is obtained from the DB) to pass it to a Flash application. This
>>>> is
>>>> the
>>>> line i'm using:
>>>>
>>>> String imageURL = assetSource.getAsset(null,
>>>> sewerGraph.getMapImagePath()
>>>> ,
>>>> threadLocale.getLocale()).toClientURL();
>>>>
>>>> The value of sewerGraph.getMapImagePath() is
>>>> "context:planos/plano1.png"
>>>> in
>>>> this example, and the result of the line above is
>>>> "../../planos/plano1.png".
>>>> This would be fine if I consider the URL of the page class in which
>>>> this
>>>> line is executed, but the problem is this page has 2 variables of
>>>> context
>>>> that onPassivate puts in the URL (the Page URL transform to
>>>> "pageURL/contextVar1/contextVar2). With that, the
>>>> ../../planos/plano1.png
>>>> is
>>>> relativa to the contextVar2 portion of the URL and then producing a
>>>> wrong
>>>> relative URL.
>>>>
>>>> What am i doing wrong? or is this a problem with context assets in the
>>>> AssetSource ?
>>>>
>>>> Regards.
>>>>
>>>> P.S.: if this is not very understandable, please ask me.... i haven't
>>>> slept
>>>> too much lately.... :(
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/Tapestry-AssetSource-tp21359198p21359198.html
>>>> Sent from the Tapestry - User 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
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Howard M. Lewis Ship
>>>
>>> Creator Apache Tapestry and Apache HiveMind
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Tapestry-AssetSource-tp21359198p21360591.html
>> Sent from the Tapestry - User 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
>>
>>
> 
> 
> 
> -- 
> Howard M. Lewis Ship
> 
> Creator Apache Tapestry and Apache HiveMind
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Tapestry-AssetSource-tp21359198p21375497.html
Sent from the Tapestry - User 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


Re: Tapestry AssetSource

Posted by Howard Lewis Ship <hl...@gmail.com>.
The relative paths are only relevant when rendering a page.  At that
time, the base URL of the rendered page is known, it is the current
request path.  The issue for you is that you are effectively changing
the base URL on the fly on the client side, and Tapestry isn't
prepared for that.

On Thu, Jan 8, 2009 at 12:44 PM, raulmt <ra...@gmail.com> wrote:
>
> Thanks Howard. But is it normal that the path optimization doesn't considers
> the context params of a page then? Are there cases where the context params
> shouldn't be considered? (I understand that is the problem with the path
> optimization, doesn't it?).
>
>
> Howard Lewis Ship wrote:
>>
>> The Link interface has a method, toAbsoluteURI(), that does what you want.
>>
>> Unfortunately, Asset doesn't have that method.
>>
>> One approach would be to override the symbol
>> SymbolConstants.FORCE_ABSOLUTE_URIS to "true".  This turns off the
>> request path optimizations that are causing you trouble.
>>
>> On Thu, Jan 8, 2009 at 11:29 AM, raulmt <ra...@gmail.com> wrote:
>>>
>>> Hi,
>>>
>>> I'm trying to obtain the URL of an image (which is in the context, but
>>> the
>>> path is obtained from the DB) to pass it to a Flash application. This is
>>> the
>>> line i'm using:
>>>
>>> String imageURL = assetSource.getAsset(null, sewerGraph.getMapImagePath()
>>> ,
>>> threadLocale.getLocale()).toClientURL();
>>>
>>> The value of sewerGraph.getMapImagePath() is "context:planos/plano1.png"
>>> in
>>> this example, and the result of the line above is
>>> "../../planos/plano1.png".
>>> This would be fine if I consider the URL of the page class in which this
>>> line is executed, but the problem is this page has 2 variables of context
>>> that onPassivate puts in the URL (the Page URL transform to
>>> "pageURL/contextVar1/contextVar2). With that, the ../../planos/plano1.png
>>> is
>>> relativa to the contextVar2 portion of the URL and then producing a wrong
>>> relative URL.
>>>
>>> What am i doing wrong? or is this a problem with context assets in the
>>> AssetSource ?
>>>
>>> Regards.
>>>
>>> P.S.: if this is not very understandable, please ask me.... i haven't
>>> slept
>>> too much lately.... :(
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Tapestry-AssetSource-tp21359198p21359198.html
>>> Sent from the Tapestry - User 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
>>>
>>>
>>
>>
>>
>> --
>> Howard M. Lewis Ship
>>
>> Creator Apache Tapestry and Apache HiveMind
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Tapestry-AssetSource-tp21359198p21360591.html
> Sent from the Tapestry - User 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
>
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

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


Re: Tapestry AssetSource

Posted by raulmt <ra...@gmail.com>.
Thanks Howard. But is it normal that the path optimization doesn't considers
the context params of a page then? Are there cases where the context params
shouldn't be considered? (I understand that is the problem with the path
optimization, doesn't it?).


Howard Lewis Ship wrote:
> 
> The Link interface has a method, toAbsoluteURI(), that does what you want.
> 
> Unfortunately, Asset doesn't have that method.
> 
> One approach would be to override the symbol
> SymbolConstants.FORCE_ABSOLUTE_URIS to "true".  This turns off the
> request path optimizations that are causing you trouble.
> 
> On Thu, Jan 8, 2009 at 11:29 AM, raulmt <ra...@gmail.com> wrote:
>>
>> Hi,
>>
>> I'm trying to obtain the URL of an image (which is in the context, but
>> the
>> path is obtained from the DB) to pass it to a Flash application. This is
>> the
>> line i'm using:
>>
>> String imageURL = assetSource.getAsset(null, sewerGraph.getMapImagePath()
>> ,
>> threadLocale.getLocale()).toClientURL();
>>
>> The value of sewerGraph.getMapImagePath() is "context:planos/plano1.png"
>> in
>> this example, and the result of the line above is
>> "../../planos/plano1.png".
>> This would be fine if I consider the URL of the page class in which this
>> line is executed, but the problem is this page has 2 variables of context
>> that onPassivate puts in the URL (the Page URL transform to
>> "pageURL/contextVar1/contextVar2). With that, the ../../planos/plano1.png
>> is
>> relativa to the contextVar2 portion of the URL and then producing a wrong
>> relative URL.
>>
>> What am i doing wrong? or is this a problem with context assets in the
>> AssetSource ?
>>
>> Regards.
>>
>> P.S.: if this is not very understandable, please ask me.... i haven't
>> slept
>> too much lately.... :(
>> --
>> View this message in context:
>> http://www.nabble.com/Tapestry-AssetSource-tp21359198p21359198.html
>> Sent from the Tapestry - User 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
>>
>>
> 
> 
> 
> -- 
> Howard M. Lewis Ship
> 
> Creator Apache Tapestry and Apache HiveMind
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Tapestry-AssetSource-tp21359198p21360591.html
Sent from the Tapestry - User 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


Re: Tapestry AssetSource

Posted by Howard Lewis Ship <hl...@gmail.com>.
The Link interface has a method, toAbsoluteURI(), that does what you want.

Unfortunately, Asset doesn't have that method.

One approach would be to override the symbol
SymbolConstants.FORCE_ABSOLUTE_URIS to "true".  This turns off the
request path optimizations that are causing you trouble.

On Thu, Jan 8, 2009 at 11:29 AM, raulmt <ra...@gmail.com> wrote:
>
> Hi,
>
> I'm trying to obtain the URL of an image (which is in the context, but the
> path is obtained from the DB) to pass it to a Flash application. This is the
> line i'm using:
>
> String imageURL = assetSource.getAsset(null, sewerGraph.getMapImagePath() ,
> threadLocale.getLocale()).toClientURL();
>
> The value of sewerGraph.getMapImagePath() is "context:planos/plano1.png" in
> this example, and the result of the line above is "../../planos/plano1.png".
> This would be fine if I consider the URL of the page class in which this
> line is executed, but the problem is this page has 2 variables of context
> that onPassivate puts in the URL (the Page URL transform to
> "pageURL/contextVar1/contextVar2). With that, the ../../planos/plano1.png is
> relativa to the contextVar2 portion of the URL and then producing a wrong
> relative URL.
>
> What am i doing wrong? or is this a problem with context assets in the
> AssetSource ?
>
> Regards.
>
> P.S.: if this is not very understandable, please ask me.... i haven't slept
> too much lately.... :(
> --
> View this message in context: http://www.nabble.com/Tapestry-AssetSource-tp21359198p21359198.html
> Sent from the Tapestry - User 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
>
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

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