You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Patrick Casey <pa...@adelphia.net> on 2005/10/03 05:51:29 UTC
Brain Freeze Assistence Please
Hi Folks,
For some reason my brain is locking up on what I'm sure is mind
numbingly simple.
I have a component template that renders a number of rows of
data.
For even rows, I want to enclose to row in a
<span class="even">ROW</span>
For odd rows, I want to enclose the row in a
<span class="odd">ROW</span>
I have a parameter I pass into the component that tells it where or not it
is even.
How do I conditionally set the class attribute (or any attribute) for that
matter? I know I can do:
<span jwcid="@Conditional" condition="ognl:even">
<span class="even">ROW</span>
</span>
<span jwcid="@Conditional" condition="ognl:odd">
<span class="odd">ROW</span>
</span>
But I *really* don't want to duplicate my row rendering code because it's
very, very large, and quite volatile so I don't want to have to duplicate
every possible future change.
So what's the way to conditionally set an attribute?
--- Pat
PS Bonus points if you can explain why I'm brain freezing so hard over this
:-).
Re: Brain Freeze Assistence Please
Posted by Leonardo Quijano Vincenzi <le...@dtqsoftware.com>.
It's not yet 11:00 PM :P
Btw... is there a way to define EvenOdd in a global way, instead of
configuring it per-page?
--
Ing. Leonardo Quijano Vincenzi
Director Técnico
DTQ Software
Darío Vasconcelos escribió:
>instead of your
>
> boolean getEven( )
>
>method, create a
>
> String getCSSClass( )
>
>that will return the class name directly, depending on whether the row
>is even or odd:
>
><span jwcid="@Any" class="ognl:CSSClass">....</span>
>
>
>As to why your brain is locked, well, it's Sunday, 11:00 PM,.. that
>pretty much explains it :-)
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Brain Freeze Assistence Please
Posted by Darío Vasconcelos <da...@gmail.com>.
Hey! That last one is much better: it keeps the CSS class name in the
HTML where it belongs, and is easier to modify...
On 10/3/05, Jamie Orchard-Hays <ja...@dang.com> wrote:
> or:
> <span jwcid="@Any" class="ognl: even ? 'evenClass' :
> 'oddClass'">....</span>
>
>
>
> On Oct 3, 2005, at 12:11 AM, Darío Vasconcelos wrote:
>
> > instead of your
> >
> > boolean getEven( )
> >
> > method, create a
> >
> > String getCSSClass( )
> >
> > that will return the class name directly, depending on whether the row
> > is even or odd:
> >
> > <span jwcid="@Any" class="ognl:CSSClass">....</span>
> >
> >
> > As to why your brain is locked, well, it's Sunday, 11:00 PM,.. that
> > pretty much explains it :-)
> >
> >
> >
> >
> > On 10/2/05, Patrick Casey <pa...@adelphia.net> wrote:
> >
> >>
> >>
> >> Hi Folks,
> >>
> >>
> >>
> >> For some reason my brain is locking up on what I'm
> >> sure is mind
> >> numbingly simple.
> >>
> >>
> >>
> >> I have a component template that renders a number of
> >> rows of
> >> data.
> >>
> >>
> >>
> >> For even rows, I want to enclose to row in a
> >>
> >> <span class="even">ROW</span>
> >>
> >>
> >>
> >> For odd rows, I want to enclose the row in a
> >>
> >> <span class="odd">ROW</span>
> >>
> >>
> >>
> >> I have a parameter I pass into the component that tells it where
> >> or not it
> >> is even.
> >>
> >>
> >>
> >> How do I conditionally set the class attribute (or any attribute)
> >> for that
> >> matter? I know I can do:
> >>
> >>
> >>
> >> <span jwcid="@Conditional" condition="ognl:even">
> >>
> >> <span class="even">ROW</span>
> >>
> >> </span>
> >>
> >>
> >>
> >> <span jwcid="@Conditional" condition="ognl:odd">
> >>
> >> <span class="odd">ROW</span>
> >>
> >> </span>
> >>
> >>
> >>
> >> But I *really* don't want to duplicate my row rendering code
> >> because it's
> >> very, very large, and quite volatile so I don't want to have to
> >> duplicate
> >> every possible future change.
> >>
> >>
> >>
> >> So what's the way to conditionally set an attribute?
> >>
> >>
> >>
> >> --- Pat
> >>
> >>
> >>
> >> PS Bonus points if you can explain why I'm brain freezing so hard
> >> over this
> >> :-).
> >>
> >>
> >>
> >>
> >
> >
> > --
> > I have enough money to last me the rest of my life, unless I buy
> > something.
> > Jackie Mason
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
--
I have enough money to last me the rest of my life, unless I buy something.
Jackie Mason
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Brain Freeze Assistence Please
Posted by Jamie Orchard-Hays <ja...@dang.com>.
or:
<span jwcid="@Any" class="ognl: even ? 'evenClass' :
'oddClass'">....</span>
On Oct 3, 2005, at 12:11 AM, Darío Vasconcelos wrote:
> instead of your
>
> boolean getEven( )
>
> method, create a
>
> String getCSSClass( )
>
> that will return the class name directly, depending on whether the row
> is even or odd:
>
> <span jwcid="@Any" class="ognl:CSSClass">....</span>
>
>
> As to why your brain is locked, well, it's Sunday, 11:00 PM,.. that
> pretty much explains it :-)
>
>
>
>
> On 10/2/05, Patrick Casey <pa...@adelphia.net> wrote:
>
>>
>>
>> Hi Folks,
>>
>>
>>
>> For some reason my brain is locking up on what I'm
>> sure is mind
>> numbingly simple.
>>
>>
>>
>> I have a component template that renders a number of
>> rows of
>> data.
>>
>>
>>
>> For even rows, I want to enclose to row in a
>>
>> <span class="even">ROW</span>
>>
>>
>>
>> For odd rows, I want to enclose the row in a
>>
>> <span class="odd">ROW</span>
>>
>>
>>
>> I have a parameter I pass into the component that tells it where
>> or not it
>> is even.
>>
>>
>>
>> How do I conditionally set the class attribute (or any attribute)
>> for that
>> matter? I know I can do:
>>
>>
>>
>> <span jwcid="@Conditional" condition="ognl:even">
>>
>> <span class="even">ROW</span>
>>
>> </span>
>>
>>
>>
>> <span jwcid="@Conditional" condition="ognl:odd">
>>
>> <span class="odd">ROW</span>
>>
>> </span>
>>
>>
>>
>> But I *really* don't want to duplicate my row rendering code
>> because it's
>> very, very large, and quite volatile so I don't want to have to
>> duplicate
>> every possible future change.
>>
>>
>>
>> So what's the way to conditionally set an attribute?
>>
>>
>>
>> --- Pat
>>
>>
>>
>> PS Bonus points if you can explain why I'm brain freezing so hard
>> over this
>> :-).
>>
>>
>>
>>
>
>
> --
> I have enough money to last me the rest of my life, unless I buy
> something.
> Jackie Mason
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Brain Freeze Assistence Please
Posted by Johan Maasing <jo...@zoom.nu>.
Patrick Casey wrote:
> Thanks, the @Any tag to the rescue once again. As for it being 11:00
> PM, well, that's the part of being self-employed folks don't usually
> advertise :).
>
> --- Pat
>
>
>>-----Original Message-----
>>From: Darío Vasconcelos [mailto:dario.vasconcelos@gmail.com]
>>Sent: Sunday, October 02, 2005 9:12 PM
>>To: Tapestry users
>>Subject: Re: Brain Freeze Assistence Please
>>
>>instead of your
>>
>> boolean getEven( )
>>
>>method, create a
>>
>> String getCSSClass( )
>>
>>that will return the class name directly, depending on whether the row
>>is even or odd:
>>
>><span jwcid="@Any" class="ognl:CSSClass">....</span>
>>
>>
>>As to why your brain is locked, well, it's Sunday, 11:00 PM,.. that
>>pretty much explains it :-)
>>
>>
>>
>>
>>On 10/2/05, Patrick Casey <pa...@adelphia.net> wrote:
>>
>>>
>>> Hi Folks,
>>>
>>>
>>>
>>> For some reason my brain is locking up on what I'm sure is
>>
>>mind
>>
>>>numbingly simple.
>>>
>>>
>>>
>>> I have a component template that renders a number of rows of
>>>data.
>>>
>>>
>>>
>>> For even rows, I want to enclose to row in a
>>>
>>><span class="even">ROW</span>
>>>
>>>
>>>
>>>For odd rows, I want to enclose the row in a
>>>
>>><span class="odd">ROW</span>
>>>
>>>
>>>
>>>I have a parameter I pass into the component that tells it where or not
>>
>>it
>>
>>>is even.
>>>
>>>
>>>
>>>How do I conditionally set the class attribute (or any attribute) for
I iterate over a search result containing authors so this is how I do it
with the Foreach component (Tapestry 3).
<bean name="evenOdd"
class="org.apache.tapestry.bean.EvenOdd"
lifecycle="request"/>
<component id="authorIterator" type="Foreach">
<binding name="source" expression="searchResult"/>
<binding name="value" expression="currentAuthor"/>
<static-binding name="element" value="tr"/>
<binding name="class" expression="beans.evenOdd.next + '
someotherclass'"/>
</component>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
RE: Brain Freeze Assistence Please
Posted by Patrick Casey <pa...@adelphia.net>.
Thanks, the @Any tag to the rescue once again. As for it being 11:00
PM, well, that's the part of being self-employed folks don't usually
advertise :).
--- Pat
> -----Original Message-----
> From: Darío Vasconcelos [mailto:dario.vasconcelos@gmail.com]
> Sent: Sunday, October 02, 2005 9:12 PM
> To: Tapestry users
> Subject: Re: Brain Freeze Assistence Please
>
> instead of your
>
> boolean getEven( )
>
> method, create a
>
> String getCSSClass( )
>
> that will return the class name directly, depending on whether the row
> is even or odd:
>
> <span jwcid="@Any" class="ognl:CSSClass">....</span>
>
>
> As to why your brain is locked, well, it's Sunday, 11:00 PM,.. that
> pretty much explains it :-)
>
>
>
>
> On 10/2/05, Patrick Casey <pa...@adelphia.net> wrote:
> >
> >
> > Hi Folks,
> >
> >
> >
> > For some reason my brain is locking up on what I'm sure is
> mind
> > numbingly simple.
> >
> >
> >
> > I have a component template that renders a number of rows of
> > data.
> >
> >
> >
> > For even rows, I want to enclose to row in a
> >
> > <span class="even">ROW</span>
> >
> >
> >
> > For odd rows, I want to enclose the row in a
> >
> > <span class="odd">ROW</span>
> >
> >
> >
> > I have a parameter I pass into the component that tells it where or not
> it
> > is even.
> >
> >
> >
> > How do I conditionally set the class attribute (or any attribute) for
> that
> > matter? I know I can do:
> >
> >
> >
> > <span jwcid="@Conditional" condition="ognl:even">
> >
> > <span class="even">ROW</span>
> >
> > </span>
> >
> >
> >
> > <span jwcid="@Conditional" condition="ognl:odd">
> >
> > <span class="odd">ROW</span>
> >
> > </span>
> >
> >
> >
> > But I *really* don't want to duplicate my row rendering code because
> it's
> > very, very large, and quite volatile so I don't want to have to
> duplicate
> > every possible future change.
> >
> >
> >
> > So what's the way to conditionally set an attribute?
> >
> >
> >
> > --- Pat
> >
> >
> >
> > PS Bonus points if you can explain why I'm brain freezing so hard over
> this
> > :-).
> >
> >
> >
>
>
> --
> I have enough money to last me the rest of my life, unless I buy
> something.
> Jackie Mason
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Brain Freeze Assistence Please
Posted by Darío Vasconcelos <da...@gmail.com>.
instead of your
boolean getEven( )
method, create a
String getCSSClass( )
that will return the class name directly, depending on whether the row
is even or odd:
<span jwcid="@Any" class="ognl:CSSClass">....</span>
As to why your brain is locked, well, it's Sunday, 11:00 PM,.. that
pretty much explains it :-)
On 10/2/05, Patrick Casey <pa...@adelphia.net> wrote:
>
>
> Hi Folks,
>
>
>
> For some reason my brain is locking up on what I'm sure is mind
> numbingly simple.
>
>
>
> I have a component template that renders a number of rows of
> data.
>
>
>
> For even rows, I want to enclose to row in a
>
> <span class="even">ROW</span>
>
>
>
> For odd rows, I want to enclose the row in a
>
> <span class="odd">ROW</span>
>
>
>
> I have a parameter I pass into the component that tells it where or not it
> is even.
>
>
>
> How do I conditionally set the class attribute (or any attribute) for that
> matter? I know I can do:
>
>
>
> <span jwcid="@Conditional" condition="ognl:even">
>
> <span class="even">ROW</span>
>
> </span>
>
>
>
> <span jwcid="@Conditional" condition="ognl:odd">
>
> <span class="odd">ROW</span>
>
> </span>
>
>
>
> But I *really* don't want to duplicate my row rendering code because it's
> very, very large, and quite volatile so I don't want to have to duplicate
> every possible future change.
>
>
>
> So what's the way to conditionally set an attribute?
>
>
>
> --- Pat
>
>
>
> PS Bonus points if you can explain why I'm brain freezing so hard over this
> :-).
>
>
>
--
I have enough money to last me the rest of my life, unless I buy something.
Jackie Mason
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org