You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jim O'Callaghan <ji...@peritussolutions.com> on 2010/07/13 17:41:39 UTC

Conditional class for body

I've run in to a situation where the CSS class used for the body of my
layout.tml varies depending on certain conditions.  I've tried using
variously:

 

<body t:class=<t:if test="xyzTest" negate="true">'xyzClass'</t:if>>

 

Or:

 

<t:if test=" xyzTest ">

                                <body class="'xyzClass'">             

                <p:else>

                                <body>

                </ p:else>

    </t:if>

 

. and several other permutations without success - I am getting variations
on parse errors with the general theme that class parameters cannot contain
quotes, or that body tag must be accompanied by closing body tag etc.

 

Can anyone suggest a working approach to this simple use case?  It's
important to be able to have the CSS class explicitly in the tml, and not
buried in a java property.

 

Thanks,

Jim.

 


Re: Conditional class for body

Posted by Pablo dos Reis <pa...@gmail.com>.
*<t:if test="xyz">


2010/7/13 Pablo dos Reis <pa...@gmail.com>

> Hi Jim,
>
> You can give an id to body and then use JavaScript.
>
>
> <script>
>    <t:if text="xyz">
>
>          $('body').addClassName('myClass');
>
>         <p:else>
>                         $('body').addClassName('otherClass');
>           </ p:else>
>    </t:if>
> </script>
>
> But I think the Michael's solution very good too.
>
>
>
> 2010/7/13 Michael Gentry <mg...@masslight.net>
>
> Hi Jim,
>>
>> I've used class="${xyzClass}" before in the past.  Then implemented
>> getXyzClass() in my .java.  You said it was important to not be in the
>> Java for you and had to be in the TML?  Why is it that important when
>> both would require a WAR redeploy in a real production environment?
>>
>> mrg
>>
>>
>> On Tue, Jul 13, 2010 at 11:41 AM, Jim O'Callaghan
>> <ji...@peritussolutions.com> wrote:
>> > I've run in to a situation where the CSS class used for the body of my
>> > layout.tml varies depending on certain conditions.  I've tried using
>> > variously:
>> >
>> >
>> >
>> > <body t:class=<t:if test="xyzTest" negate="true">'xyzClass'</t:if>>
>> >
>> >
>> >
>> > Or:
>> >
>> >
>> >
>> > <t:if test=" xyzTest ">
>> >
>> >                                <body class="'xyzClass'">
>> >
>> >                <p:else>
>> >
>> >                                <body>
>> >
>> >                </ p:else>
>> >
>> >    </t:if>
>> >
>> >
>> >
>> > . and several other permutations without success - I am getting
>> variations
>> > on parse errors with the general theme that class parameters cannot
>> contain
>> > quotes, or that body tag must be accompanied by closing body tag etc.
>> >
>> >
>> >
>> > Can anyone suggest a working approach to this simple use case?  It's
>> > important to be able to have the CSS class explicitly in the tml, and
>> not
>> > buried in a java property.
>> >
>> >
>> >
>> > Thanks,
>> >
>> > Jim.
>> >
>> >
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
>
> --
> Pablo Henrique dos Reis
>
>


-- 
Pablo Henrique dos Reis

Re: Conditional class for body

Posted by Pablo dos Reis <pa...@gmail.com>.
Hi Jim,

You can give an id to body and then use JavaScript.


<script>
   <t:if text="xyz">

         $('body').addClassName('myClass');

        <p:else>
                        $('body').addClassName('otherClass');
          </ p:else>
   </t:if>
</script>

But I think the Michael's solution very good too.



2010/7/13 Michael Gentry <mg...@masslight.net>

> Hi Jim,
>
> I've used class="${xyzClass}" before in the past.  Then implemented
> getXyzClass() in my .java.  You said it was important to not be in the
> Java for you and had to be in the TML?  Why is it that important when
> both would require a WAR redeploy in a real production environment?
>
> mrg
>
>
> On Tue, Jul 13, 2010 at 11:41 AM, Jim O'Callaghan
> <ji...@peritussolutions.com> wrote:
> > I've run in to a situation where the CSS class used for the body of my
> > layout.tml varies depending on certain conditions.  I've tried using
> > variously:
> >
> >
> >
> > <body t:class=<t:if test="xyzTest" negate="true">'xyzClass'</t:if>>
> >
> >
> >
> > Or:
> >
> >
> >
> > <t:if test=" xyzTest ">
> >
> >                                <body class="'xyzClass'">
> >
> >                <p:else>
> >
> >                                <body>
> >
> >                </ p:else>
> >
> >    </t:if>
> >
> >
> >
> > . and several other permutations without success - I am getting
> variations
> > on parse errors with the general theme that class parameters cannot
> contain
> > quotes, or that body tag must be accompanied by closing body tag etc.
> >
> >
> >
> > Can anyone suggest a working approach to this simple use case?  It's
> > important to be able to have the CSS class explicitly in the tml, and not
> > buried in a java property.
> >
> >
> >
> > Thanks,
> >
> > Jim.
> >
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Pablo Henrique dos Reis

RE: Conditional class for body

Posted by Jim O'Callaghan <jc...@yahoo.co.uk>.
Thiago, Pablo,

Thanks for the replies.  I'll try one of those methods.

Regards,
Jim.

-----Original Message-----
From: Thiago H. de Paula Figueiredo [mailto:thiagohp@gmail.com] 
Sent: 13 July 2010 17:11
To: Tapestry users
Subject: Re: Conditional class for body

On Tue, 13 Jul 2010 13:01:35 -0300, Jim O'Callaghan  
<jc...@yahoo.co.uk> wrote:

> Thanks for the quick response Michael.  The reason the CSS class name  
> needs to be present in the tml is that I am not in control of the CSS /  
> overall
> look of the app, and some of the CSS / front-end people may not  
> necessarily know where to look within the java code.  I guess if no  
> other solutions are apparent I can use the property approach.

Just make your Java method look for the class name in some appropriate  
place (properties file, etc).

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, 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



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


Re: Conditional class for body

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 13 Jul 2010 13:01:35 -0300, Jim O'Callaghan  
<jc...@yahoo.co.uk> wrote:

> Thanks for the quick response Michael.  The reason the CSS class name  
> needs to be present in the tml is that I am not in control of the CSS /  
> overall
> look of the app, and some of the CSS / front-end people may not  
> necessarily know where to look within the java code.  I guess if no  
> other solutions are apparent I can use the property approach.

Just make your Java method look for the class name in some appropriate  
place (properties file, etc).

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, 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: Conditional class for body

Posted by Jim O'Callaghan <jc...@yahoo.co.uk>.
Thanks for the quick response Michael.  The reason the CSS class name needs
to be present in the tml is that I am not in control of the CSS / overall
look of the app, and some of the CSS / front-end people may not necessarily
know where to look within the java code.  I guess if no other solutions are
apparent I can use the property approach.

Regards,
Jim.

-----Original Message-----
From: Michael Gentry [mailto:mgentry@masslight.net] 
Sent: 13 July 2010 16:48
To: Tapestry users
Subject: Re: Conditional class for body

Hi Jim,

I've used class="${xyzClass}" before in the past.  Then implemented
getXyzClass() in my .java.  You said it was important to not be in the
Java for you and had to be in the TML?  Why is it that important when
both would require a WAR redeploy in a real production environment?

mrg


On Tue, Jul 13, 2010 at 11:41 AM, Jim O'Callaghan
<ji...@peritussolutions.com> wrote:
> I've run in to a situation where the CSS class used for the body of my
> layout.tml varies depending on certain conditions.  I've tried using
> variously:
>
>
>
> <body t:class=<t:if test="xyzTest" negate="true">'xyzClass'</t:if>>
>
>
>
> Or:
>
>
>
> <t:if test=" xyzTest ">
>
>                                <body class="'xyzClass'">
>
>                <p:else>
>
>                                <body>
>
>                </ p:else>
>
>    </t:if>
>
>
>
> . and several other permutations without success - I am getting variations
> on parse errors with the general theme that class parameters cannot
contain
> quotes, or that body tag must be accompanied by closing body tag etc.
>
>
>
> Can anyone suggest a working approach to this simple use case?  It's
> important to be able to have the CSS class explicitly in the tml, and not
> buried in a java property.
>
>
>
> Thanks,
>
> Jim.
>
>
>
>

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



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


Re: Conditional class for body

Posted by Michael Gentry <mg...@masslight.net>.
Hi Jim,

I've used class="${xyzClass}" before in the past.  Then implemented
getXyzClass() in my .java.  You said it was important to not be in the
Java for you and had to be in the TML?  Why is it that important when
both would require a WAR redeploy in a real production environment?

mrg


On Tue, Jul 13, 2010 at 11:41 AM, Jim O'Callaghan
<ji...@peritussolutions.com> wrote:
> I've run in to a situation where the CSS class used for the body of my
> layout.tml varies depending on certain conditions.  I've tried using
> variously:
>
>
>
> <body t:class=<t:if test="xyzTest" negate="true">'xyzClass'</t:if>>
>
>
>
> Or:
>
>
>
> <t:if test=" xyzTest ">
>
>                                <body class="'xyzClass'">
>
>                <p:else>
>
>                                <body>
>
>                </ p:else>
>
>    </t:if>
>
>
>
> . and several other permutations without success - I am getting variations
> on parse errors with the general theme that class parameters cannot contain
> quotes, or that body tag must be accompanied by closing body tag etc.
>
>
>
> Can anyone suggest a working approach to this simple use case?  It's
> important to be able to have the CSS class explicitly in the tml, and not
> buried in a java property.
>
>
>
> Thanks,
>
> Jim.
>
>
>
>

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