You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by bogdan_cm <bo...@rbccm.com> on 2011/04/05 03:57:43 UTC
Using @Environmental and "JavaScriptSupport Object" to dynamically
load css based on browser
Hi,
There is one post regarding this here:
http://tapestry.1045711.n5.nabble.com/Using-conditional-comments-with-Import-stylesheet-quot-quot-td3827508.html#a3887176
http://tapestry.1045711.n5.nabble.com/Using-conditional-comments-with-Import-stylesheet-quot-quot-td3827508.html#a3887176
but I find myself unable to figure out how it's done. Is there a working
demo somewhere, or can anyone post a bare bones class-template example
please?
Thank you,
Bogdan.
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Using-Environmental-and-JavaScriptSupport-Object-to-dynamically-load-css-based-on-browser-tp4283102p4283102.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: Using @Environmental and "JavaScriptSupport Object" to
dynamically load css based on browser
Posted by bogdan_cm <bo...@rbccm.com>.
Very useful stuff. Thanks very much for replies.
Cheers,
Bogdan.
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Using-Environmental-and-JavaScriptSupport-Object-to-dynamically-load-css-based-on-browser-tp4283102p4298913.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: Using @Environmental and "JavaScriptSupport Object" to
dynamically load css based on browser
Posted by Massimo Lusetti <ml...@gmail.com>.
On Wed, Apr 6, 2011 at 12:51 PM, Bob Harner <bo...@gmail.com> wrote:
> I updated the docs at http://tapestry.apache.org/css.html based on Howard's
> answer.
Thanks Bob!
Cheers
--
Massimo
http://meridio.blogspot.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Using @Environmental and "JavaScriptSupport Object" to
dynamically load css based on browser
Posted by Bob Harner <bo...@gmail.com>.
I updated the docs at http://tapestry.apache.org/css.html based on Howard's
answer.
On Apr 5, 2011 8:32 PM, "Taha Hafeez" <ta...@gmail.com> wrote:
> Sorry typo!!
>
> On Wed, Apr 6, 2011 at 3:25 AM, Howard Lewis Ship <hl...@gmail.com>
wrote:
>
>> Oops, sorry Taha, you got this a bit wrong.
>>
>> You use @Inject on a field, so this would be
>>
>> @Inject
>> private Request request;
>>
>>
>>
>> The rest is the same ...
>>
>> ... but Tapestry supports IE conditional stylesheets, which is much
>> more accurate than checking the User-Agent header:
>>
>> @Inject @Path("ie-only.css")
>> private Asset ieOnlyStylesheet;
>>
>> void afterRender() {
>> javaScriptSupport.importStylesheet(new
>> StylesheetLink(ieOnlyStylesheet, new StylesheetOptions(null, "IE")));
>> }
>>
>> On Mon, Apr 4, 2011 at 8:07 PM, Taha Hafeez <ta...@gmail.com>
>> wrote:
>> > Hi Bogdan,
>> >
>> > in your class you have import javascriptSupport and request object
>> >
>> > public class MyPage {
>> >
>> > @Environmental
>> > private JavaScriptSupport javaScriptSupport;
>> >
>> > @Import
>> > private Request request;
>> >
>> > void afterRender(){
>> > String userAgent = request.getHeader("User-Agent");
>> > //Your logic
>> > if(userAgent.contains("MSIE")){
>> > javaScriptSupport.importStylesheet(...);
>> > }else .....
>> > }
>> > }
>> >
>> >
>> > regards
>> > Taha
>> >
>> >
>> > On Tue, Apr 5, 2011 at 7:27 AM, bogdan_cm <bo...@rbccm.com>
>> wrote:
>> >
>> >> Hi,
>> >> There is one post regarding this here:
>> >>
>> >>
>>
http://tapestry.1045711.n5.nabble.com/Using-conditional-comments-with-Import-stylesheet-quot-quot-td3827508.html#a3887176
>> >>
>> >>
>>
http://tapestry.1045711.n5.nabble.com/Using-conditional-comments-with-Import-stylesheet-quot-quot-td3827508.html#a3887176
>> >>
>> >> but I find myself unable to figure out how it's done. Is there a
working
>> >> demo somewhere, or can anyone post a bare bones class-template example
>> >> please?
>> >>
>> >> Thank you,
>> >> Bogdan.
>> >>
>> >>
>> >> --
>> >> View this message in context:
>> >>
>>
http://tapestry.1045711.n5.nabble.com/Using-Environmental-and-JavaScriptSupport-Object-to-dynamically-load-css-based-on-browser-tp4283102p4283102.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 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: Using @Environmental and "JavaScriptSupport Object" to
dynamically load css based on browser
Posted by Taha Hafeez <ta...@gmail.com>.
Sorry typo!!
On Wed, Apr 6, 2011 at 3:25 AM, Howard Lewis Ship <hl...@gmail.com> wrote:
> Oops, sorry Taha, you got this a bit wrong.
>
> You use @Inject on a field, so this would be
>
> @Inject
> private Request request;
>
>
>
> The rest is the same ...
>
> ... but Tapestry supports IE conditional stylesheets, which is much
> more accurate than checking the User-Agent header:
>
> @Inject @Path("ie-only.css")
> private Asset ieOnlyStylesheet;
>
> void afterRender() {
> javaScriptSupport.importStylesheet(new
> StylesheetLink(ieOnlyStylesheet, new StylesheetOptions(null, "IE")));
> }
>
> On Mon, Apr 4, 2011 at 8:07 PM, Taha Hafeez <ta...@gmail.com>
> wrote:
> > Hi Bogdan,
> >
> > in your class you have import javascriptSupport and request object
> >
> > public class MyPage {
> >
> > @Environmental
> > private JavaScriptSupport javaScriptSupport;
> >
> > @Import
> > private Request request;
> >
> > void afterRender(){
> > String userAgent = request.getHeader("User-Agent");
> > //Your logic
> > if(userAgent.contains("MSIE")){
> > javaScriptSupport.importStylesheet(...);
> > }else .....
> > }
> > }
> >
> >
> > regards
> > Taha
> >
> >
> > On Tue, Apr 5, 2011 at 7:27 AM, bogdan_cm <bo...@rbccm.com>
> wrote:
> >
> >> Hi,
> >> There is one post regarding this here:
> >>
> >>
> http://tapestry.1045711.n5.nabble.com/Using-conditional-comments-with-Import-stylesheet-quot-quot-td3827508.html#a3887176
> >>
> >>
> http://tapestry.1045711.n5.nabble.com/Using-conditional-comments-with-Import-stylesheet-quot-quot-td3827508.html#a3887176
> >>
> >> but I find myself unable to figure out how it's done. Is there a working
> >> demo somewhere, or can anyone post a bare bones class-template example
> >> please?
> >>
> >> Thank you,
> >> Bogdan.
> >>
> >>
> >> --
> >> View this message in context:
> >>
> http://tapestry.1045711.n5.nabble.com/Using-Environmental-and-JavaScriptSupport-Object-to-dynamically-load-css-based-on-browser-tp4283102p4283102.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 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: Using @Environmental and "JavaScriptSupport Object" to
dynamically load css based on browser
Posted by Howard Lewis Ship <hl...@gmail.com>.
Oops, sorry Taha, you got this a bit wrong.
You use @Inject on a field, so this would be
@Inject
private Request request;
The rest is the same ...
... but Tapestry supports IE conditional stylesheets, which is much
more accurate than checking the User-Agent header:
@Inject @Path("ie-only.css")
private Asset ieOnlyStylesheet;
void afterRender() {
javaScriptSupport.importStylesheet(new
StylesheetLink(ieOnlyStylesheet, new StylesheetOptions(null, "IE")));
}
On Mon, Apr 4, 2011 at 8:07 PM, Taha Hafeez <ta...@gmail.com> wrote:
> Hi Bogdan,
>
> in your class you have import javascriptSupport and request object
>
> public class MyPage {
>
> @Environmental
> private JavaScriptSupport javaScriptSupport;
>
> @Import
> private Request request;
>
> void afterRender(){
> String userAgent = request.getHeader("User-Agent");
> //Your logic
> if(userAgent.contains("MSIE")){
> javaScriptSupport.importStylesheet(...);
> }else .....
> }
> }
>
>
> regards
> Taha
>
>
> On Tue, Apr 5, 2011 at 7:27 AM, bogdan_cm <bo...@rbccm.com> wrote:
>
>> Hi,
>> There is one post regarding this here:
>>
>> http://tapestry.1045711.n5.nabble.com/Using-conditional-comments-with-Import-stylesheet-quot-quot-td3827508.html#a3887176
>>
>> http://tapestry.1045711.n5.nabble.com/Using-conditional-comments-with-Import-stylesheet-quot-quot-td3827508.html#a3887176
>>
>> but I find myself unable to figure out how it's done. Is there a working
>> demo somewhere, or can anyone post a bare bones class-template example
>> please?
>>
>> Thank you,
>> Bogdan.
>>
>>
>> --
>> View this message in context:
>> http://tapestry.1045711.n5.nabble.com/Using-Environmental-and-JavaScriptSupport-Object-to-dynamically-load-css-based-on-browser-tp4283102p4283102.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 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: Using @Environmental and "JavaScriptSupport Object" to
dynamically load css based on browser
Posted by Taha Hafeez <ta...@gmail.com>.
Hi Bogdan,
in your class you have import javascriptSupport and request object
public class MyPage {
@Environmental
private JavaScriptSupport javaScriptSupport;
@Import
private Request request;
void afterRender(){
String userAgent = request.getHeader("User-Agent");
//Your logic
if(userAgent.contains("MSIE")){
javaScriptSupport.importStylesheet(...);
}else .....
}
}
regards
Taha
On Tue, Apr 5, 2011 at 7:27 AM, bogdan_cm <bo...@rbccm.com> wrote:
> Hi,
> There is one post regarding this here:
>
> http://tapestry.1045711.n5.nabble.com/Using-conditional-comments-with-Import-stylesheet-quot-quot-td3827508.html#a3887176
>
> http://tapestry.1045711.n5.nabble.com/Using-conditional-comments-with-Import-stylesheet-quot-quot-td3827508.html#a3887176
>
> but I find myself unable to figure out how it's done. Is there a working
> demo somewhere, or can anyone post a bare bones class-template example
> please?
>
> Thank you,
> Bogdan.
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Using-Environmental-and-JavaScriptSupport-Object-to-dynamically-load-css-based-on-browser-tp4283102p4283102.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: Using @Environmental and "JavaScriptSupport Object" to
dynamically load css based on browser
Posted by bogdan_cm <bo...@rbccm.com>.
Thank you very much for the responses. very useful stuff.
Cheers.
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Using-Environmental-and-JavaScriptSupport-Object-to-dynamically-load-css-based-on-browser-tp4283102p4298887.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