You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Thomas Cucchietti <th...@gmail.com> on 2010/02/24 11:52:29 UTC

[T5]New locale management and CSS path

Hello everybody,

As it is linked to a pretty recent behavior (since T 5.1 apparently), I've
not found information about the following problem :

The new locale management system (no more cookie, but locale added in the
root URL) has a side effect on my application.

I'm used to include my stylesheets using the render support in my base page
like this :

    renderSupport.addStylesheetLink("static/css/common.css", null);

However, I've lost my stylesheets since now the link added in a page has
this pattern :

<rootURL>/<locale>/static/css/common.css

Any one has an idea?

Thomas CUCCHIETTI.

Re: [T5]New locale management and CSS path

Posted by Howard Lewis Ship <hl...@gmail.com>.
To be clear, @IncludeStylesheet is just some meta-programming; it
ultimately goes through RenderSupport just like the hand-tooled code.

On Wed, Feb 24, 2010 at 2:22 PM, Howard Lewis Ship <hl...@gmail.com> wrote:
> How about something simpler, like
>
> @IncludeStylesheet("context:static/css/form.css")
> public class MyComponent { ... }
>
> Let Tapestry do the heavy lifting.
>
> What you are providing there is an asset path.  The "context:" part
> indicates that the file in question is in the web application context
> ("classpath:" is a built-in alternative, for files stored inside JARs
> on the classpath).
>
> Tapestry will ensure that a proper link is built from your page to the
> indicated asset.
>
> This isn't just an issue for localization; using a page activation
> context can also change the base URL for the page and break relative
> links to assets. You should always let Tapestry do what it's good at
> ... figuring these things out so you don't have to.
>
> On Wed, Feb 24, 2010 at 6:03 AM, Thomas Cucchietti
> <th...@gmail.com> wrote:
>> Hello Thiago!
>>
>> Your proposal was (again) the good solution, so thanks a lot :o)
>>
>> Here follows the code :
>>
>>    @SetupRender
>>    void setup(){
>>        Asset asset = assetSource.getContextAsset("static/css/form.css",
>> null);
>>        renderSupport.addStylesheetLink(asset,null);
>>        ...
>>    }
>>
>> Which is rendered in HTML as :
>>
>> <link href="/assets/ctx/76f6e908f48d0e66/static/css/form.css"
>> rel="stylesheet" type="text/css">
>>
>> Have a nice day!
>>
>> Thomas.
>>
>> 2010/2/24 Thiago H. de Paula Figueiredo <th...@gmail.com>
>>
>>> On Wed, 24 Feb 2010 10:18:18 -0300, Thomas Cucchietti <
>>> thomas.cucchietti@gmail.com> wrote:
>>>
>>>  Alexander,
>>>>
>>>> this was the first thing I tried to do :
>>>>
>>>> @SetupRender
>>>>    void setup(){
>>>>        renderSupport.addStylesheetLink("context:static/css/form.css",
>>>> null);
>>>>        ....
>>>>    }
>>>>
>>>
>>> @Inject AssertSource and use one of its methods to get an Asset pointing to
>>> your file. Then add it using RenderSupport.addStylesheetLink(Asset asset).
>>>
>>> --
>>> Thiago H. de Paula Figueiredo
>>> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
>>> and instructor
>>> Owner, software architect and developer, Ars Machina Tecnologia da
>>> Informação Ltda.
>>> http://www.arsmachina.com.br
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>
>
>
>
> --
> Howard M. Lewis Ship
>
> Creator of Apache Tapestry
>
> The source for Tapestry training, mentoring and support. Contact me to
> learn how I can get you up and productive in Tapestry fast!
>
> (971) 678-5210
> http://howardlewisship.com
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

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


Re: [T5]New locale management and CSS path

Posted by Howard Lewis Ship <hl...@gmail.com>.
How about something simpler, like

@IncludeStylesheet("context:static/css/form.css")
public class MyComponent { ... }

Let Tapestry do the heavy lifting.

What you are providing there is an asset path.  The "context:" part
indicates that the file in question is in the web application context
("classpath:" is a built-in alternative, for files stored inside JARs
on the classpath).

Tapestry will ensure that a proper link is built from your page to the
indicated asset.

This isn't just an issue for localization; using a page activation
context can also change the base URL for the page and break relative
links to assets. You should always let Tapestry do what it's good at
... figuring these things out so you don't have to.

On Wed, Feb 24, 2010 at 6:03 AM, Thomas Cucchietti
<th...@gmail.com> wrote:
> Hello Thiago!
>
> Your proposal was (again) the good solution, so thanks a lot :o)
>
> Here follows the code :
>
>    @SetupRender
>    void setup(){
>        Asset asset = assetSource.getContextAsset("static/css/form.css",
> null);
>        renderSupport.addStylesheetLink(asset,null);
>        ...
>    }
>
> Which is rendered in HTML as :
>
> <link href="/assets/ctx/76f6e908f48d0e66/static/css/form.css"
> rel="stylesheet" type="text/css">
>
> Have a nice day!
>
> Thomas.
>
> 2010/2/24 Thiago H. de Paula Figueiredo <th...@gmail.com>
>
>> On Wed, 24 Feb 2010 10:18:18 -0300, Thomas Cucchietti <
>> thomas.cucchietti@gmail.com> wrote:
>>
>>  Alexander,
>>>
>>> this was the first thing I tried to do :
>>>
>>> @SetupRender
>>>    void setup(){
>>>        renderSupport.addStylesheetLink("context:static/css/form.css",
>>> null);
>>>        ....
>>>    }
>>>
>>
>> @Inject AssertSource and use one of its methods to get an Asset pointing to
>> your file. Then add it using RenderSupport.addStylesheetLink(Asset asset).
>>
>> --
>> Thiago H. de Paula Figueiredo
>> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
>> and instructor
>> Owner, software architect and developer, Ars Machina Tecnologia da
>> Informação Ltda.
>> http://www.arsmachina.com.br
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

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


Re: [T5]New locale management and CSS path

Posted by Thomas Cucchietti <th...@gmail.com>.
Hello Thiago!

Your proposal was (again) the good solution, so thanks a lot :o)

Here follows the code :

    @SetupRender
    void setup(){
        Asset asset = assetSource.getContextAsset("static/css/form.css",
null);
        renderSupport.addStylesheetLink(asset,null);
        ...
    }

Which is rendered in HTML as :

<link href="/assets/ctx/76f6e908f48d0e66/static/css/form.css"
rel="stylesheet" type="text/css">

Have a nice day!

Thomas.

2010/2/24 Thiago H. de Paula Figueiredo <th...@gmail.com>

> On Wed, 24 Feb 2010 10:18:18 -0300, Thomas Cucchietti <
> thomas.cucchietti@gmail.com> wrote:
>
>  Alexander,
>>
>> this was the first thing I tried to do :
>>
>> @SetupRender
>>    void setup(){
>>        renderSupport.addStylesheetLink("context:static/css/form.css",
>> null);
>>        ....
>>    }
>>
>
> @Inject AssertSource and use one of its methods to get an Asset pointing to
> your file. Then add it using RenderSupport.addStylesheetLink(Asset asset).
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> and instructor
> Owner, software architect and developer, Ars Machina Tecnologia da
> Informação Ltda.
> http://www.arsmachina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: [T5]New locale management and CSS path

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Wed, 24 Feb 2010 10:18:18 -0300, Thomas Cucchietti  
<th...@gmail.com> wrote:

> Alexander,
>
> this was the first thing I tried to do :
>
> @SetupRender
>     void setup(){
>         renderSupport.addStylesheetLink("context:static/css/form.css",
> null);
>         ....
>     }

@Inject AssertSource and use one of its methods to get an Asset pointing  
to your file. Then add it using RenderSupport.addStylesheetLink(Asset  
asset).

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.
http://www.arsmachina.com.br

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


Re: [T5]New locale management and CSS path

Posted by Thomas Cucchietti <th...@gmail.com>.
Alexander,

this was the first thing I tried to do :

@SetupRender
    void setup(){
        renderSupport.addStylesheetLink("context:static/css/form.css",
null);
        ....
    }

But the HTML result is :

<link href="context:static/css/form.css" rel="stylesheet" type="text/css">

And my styles aren't used.

Thomas.

2010/2/24 Alexander Kiel <al...@gmx.net>

> Hi Thomas,
>
> please try to use:
>
> renderSupport.addStylesheetLink("context:static/css/common.css", null);
>
> The "context:" prefix should point to your document root of your webapp.
>
> Regards
> Alex
>
> On Wed, 2010-02-24 at 11:52 +0100, Thomas Cucchietti wrote:
> > Hello everybody,
> >
> > As it is linked to a pretty recent behavior (since T 5.1 apparently),
> I've
> > not found information about the following problem :
> >
> > The new locale management system (no more cookie, but locale added in the
> > root URL) has a side effect on my application.
> >
> > I'm used to include my stylesheets using the render support in my base
> page
> > like this :
> >
> >     renderSupport.addStylesheetLink("static/css/common.css", null);
> >
> > However, I've lost my stylesheets since now the link added in a page has
> > this pattern :
> >
> > <rootURL>/<locale>/static/css/common.css
> >
> > Any one has an idea?
> >
> > Thomas CUCCHIETTI.
>
>
> --
> mobile: +49 (0) 176 6152 9741
> phone:  +49 (0) 341 2289 188
> e-mail: alexanderkiel@gmx.net
> web:    www.alexanderkiel.net
>
>

Re: [T5]New locale management and CSS path

Posted by Alexander Kiel <al...@gmx.net>.
Hi Thomas,

please try to use:

renderSupport.addStylesheetLink("context:static/css/common.css", null);

The "context:" prefix should point to your document root of your webapp.

Regards
Alex

On Wed, 2010-02-24 at 11:52 +0100, Thomas Cucchietti wrote:
> Hello everybody,
> 
> As it is linked to a pretty recent behavior (since T 5.1 apparently), I've
> not found information about the following problem :
> 
> The new locale management system (no more cookie, but locale added in the
> root URL) has a side effect on my application.
> 
> I'm used to include my stylesheets using the render support in my base page
> like this :
> 
>     renderSupport.addStylesheetLink("static/css/common.css", null);
> 
> However, I've lost my stylesheets since now the link added in a page has
> this pattern :
> 
> <rootURL>/<locale>/static/css/common.css
> 
> Any one has an idea?
> 
> Thomas CUCCHIETTI.


-- 
mobile: +49 (0) 176 6152 9741
phone:  +49 (0) 341 2289 188
e-mail: alexanderkiel@gmx.net
web:    www.alexanderkiel.net