You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by John Doe <ni...@yahoo.com> on 2010/09/14 10:01:32 UTC

Alternating table rows

Hello,

I am new to Tapestry, but I am working on a project that uses it. The version is 
5.

I am trying to make a HTML table in which even rows have one class, and odd rows 
have another class.

So far, I tried the following (I am showing just the code that matters):

<t:loop index="index" source="list" value="element">
    <tr class="${(index % 2 == 0) ? 'even' : 'odd'}"></tr>
</t:loop>

This causes an exception: "Could not convert '(index % 2 == 0) ? 'even' : 'odd'' 
into a component parameter binding: Error parsing property expression '(index % 
2 == 0) ? 'even' : 'odd'': Unable to parse input at character position 8.".

<t:loop index="index" source="list" value="element">
    <t:if test="index % 2 == 0">
        <tr class="even">
        <t:parameter name="else">
            <tr class="odd">
        </t:parameter>
    </t:if>
    </tr>
</t:loop>

This causes an exception: "Block parameters are only allowed directly within 
component elements.".

>From this page http://tapestry.apache.org/tapestry5/guide/propexp.html I can't 
find any examples of conditionals.

How can I make the alternating rows?



      

Re: Alternating table rows

Posted by Dmitry Gusev <dm...@gmail.com>.
For alternating rows you can try CSS :nth-child(N) pseudoclass (google for
details).
<http://reference.sitepoint.com/css/pseudoclass-nthchild>Here's quick
example:


.rowClass:hover, .rowClass:nth-child(even):hover {
    background-color: #DCE5FF;
}

.rowClass:nth-child(even) {
    background-color: #E8E8E8;
}


On Tue, Sep 14, 2010 at 18:26, Davor Hrg <hr...@gmail.com> wrote:

> here is a neat and reusable trick on tapestry5howtos
>
> http://wiki.apache.org/tapestry/Tapestry5HowToAddBindingPrefixCycle
>
> Davor Hrg
>
> On Tue, Sep 14, 2010 at 10:01 AM, John Doe <ni...@yahoo.com> wrote:
>
> > Hello,
> >
> > I am new to Tapestry, but I am working on a project that uses it. The
> > version is
> > 5.
> >
> > I am trying to make a HTML table in which even rows have one class, and
> odd
> > rows
> > have another class.
> >
> > So far, I tried the following (I am showing just the code that matters):
> >
> > <t:loop index="index" source="list" value="element">
> >    <tr class="${(index % 2 == 0) ? 'even' : 'odd'}"></tr>
> > </t:loop>
> >
> > This causes an exception: "Could not convert '(index % 2 == 0) ? 'even' :
> > 'odd''
> > into a component parameter binding: Error parsing property expression
> > '(index %
> > 2 == 0) ? 'even' : 'odd'': Unable to parse input at character position
> 8.".
> >
> > <t:loop index="index" source="list" value="element">
> >    <t:if test="index % 2 == 0">
> >        <tr class="even">
> >        <t:parameter name="else">
> >            <tr class="odd">
> >        </t:parameter>
> >    </t:if>
> >    </tr>
> > </t:loop>
> >
> > This causes an exception: "Block parameters are only allowed directly
> > within
> > component elements.".
> >
> > From this page http://tapestry.apache.org/tapestry5/guide/propexp.html I
> > can't
> > find any examples of conditionals.
> >
> > How can I make the alternating rows?
> >
> >
> >
> >
>



-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com

Re: Alternating table rows

Posted by Davor Hrg <hr...@gmail.com>.
here is a neat and reusable trick on tapestry5howtos

http://wiki.apache.org/tapestry/Tapestry5HowToAddBindingPrefixCycle

Davor Hrg

On Tue, Sep 14, 2010 at 10:01 AM, John Doe <ni...@yahoo.com> wrote:

> Hello,
>
> I am new to Tapestry, but I am working on a project that uses it. The
> version is
> 5.
>
> I am trying to make a HTML table in which even rows have one class, and odd
> rows
> have another class.
>
> So far, I tried the following (I am showing just the code that matters):
>
> <t:loop index="index" source="list" value="element">
>    <tr class="${(index % 2 == 0) ? 'even' : 'odd'}"></tr>
> </t:loop>
>
> This causes an exception: "Could not convert '(index % 2 == 0) ? 'even' :
> 'odd''
> into a component parameter binding: Error parsing property expression
> '(index %
> 2 == 0) ? 'even' : 'odd'': Unable to parse input at character position 8.".
>
> <t:loop index="index" source="list" value="element">
>    <t:if test="index % 2 == 0">
>        <tr class="even">
>        <t:parameter name="else">
>            <tr class="odd">
>        </t:parameter>
>    </t:if>
>    </tr>
> </t:loop>
>
> This causes an exception: "Block parameters are only allowed directly
> within
> component elements.".
>
> From this page http://tapestry.apache.org/tapestry5/guide/propexp.html I
> can't
> find any examples of conditionals.
>
> How can I make the alternating rows?
>
>
>
>

Re: Alternating table rows

Posted by Bob Harner <bo...@gmail.com>.
This alternating stripes effect is such a common need that I think it should
be a built-in capability of all of the looping components, as a parameter in
which you pass the names of the CSS classes to alternatively apply. JSF does
this, and it's very handy. I guess you could do this yourself with a custom
loop component that accepts a "classes=odd,even" parameter, but it'd be nice
to not have to.

On Sep 14, 2010 6:00 AM, "Peter Stavrinides" <P....@albourne.com>
wrote:
> Katia has some good advice, I am also a strong advocate for code
separation, which equates to extensibility and maintanability.
>
> Your page class (pure Java) is intended to replace JSP or any expression
language, queries and any other business logic is better when moved into IoC
where it is injectable and reusable. Tapestry purposefully minimizes
expression language usage in pages because:
> - Its hard (or near impossible) to test in templates
> - It clutters the templates (error prone)
> - Its better done in Java where you can debug it (that's reason enough for
me)
> - Its NOT clean code seperation
>
> If you are doing any more than trivial conditional evaluation in templates
then it is not clean markup. Its also good to keep your templates and page
classes as minimalistic as possible so that your UI can become pluggable if
ever required.
>
> Cheers,
> Peter
>
>
> ----- Original Message -----
> From: "Katia Aresti Gonzalez" <ka...@gmail.com>
> To: "Tapestry users" <us...@tapestry.apache.org>
> Sent: Tuesday, 14 September, 2010 12:35:43 GMT +02:00 Athens, Beirut,
Bucharest, Istanbul
> Subject: Re: Alternating table rows
>
> For java CSS logic reticent people :
>
> Imagine you need more complex css logic depending not only on even/odd
row,
> but on the number of the elements you have in your table too, or even the
> values of these elements, and depending on a pagination component too. How
> will you TML look like ? like an old horrible JSP. Not only that, you
won't
> be able to do everything you did before to manage this kind of logic, as
TML
> are correct XML files.
>
> I think that putting this kind "css logic" in the TML is just a bad idea.
> This is the way to code JSP. JSP-s are not readable, they are a pain, and
> separation between class and code is just not true in real world (In JSP,
we
> usually had to put java code to manage this kind of logic).
> You will repeat yourself all over and over in your application, your code
> won't be readable, neither cleaner, maintainable and you separation
between
> styles and just code won't be better.
>
> Think in "odd" and "even" as identifiers, and let to your TML to add
another
> css class too, just as an example for your case like this :
>
> <tr class="myClassName ${switchedClass}">
>
> If you have a look to Tapestry Grid component source code, you will see
how,
> for example, the generic CSS name as "t-first" or "t-last" are applied to
> the first and last row. You can add your own css class too to the grid,
this
> class will be rendered, so within t-first and t-last, you will be able to
> overload a different style just for the first or the last row in the Grid.
> MCV pattern just works perfect.
>
>
> 2010/9/14 Gunnar Eketrapp <gu...@gmail.com>
>
>> Hi John! (Still alive ?)
>>
>> I was also frustrated about the simplicity of the template language at
the
>> start.
>> You can't (or couldn't even) negate a test!
>>
>> But the philosophy of T5 is to put all logic in java ... and after using
T5
>> succesfully in a big rewrite of an existing site I must say that I agree
>> with this.
>>
>> I added following utility methods in my base class ...
>>
>> //
>> -----------------------------------------------------------------------
>> // -- Utility methods for all our children --
>> //
>> -----------------------------------------------------------------------
>>
>> private boolean odd = true;
>>
>> public String getOddOrEvenStep() {
>> odd = !odd;
>> return odd ? "odd" : "even";
>> }
>> public String getOddOrEvenStay() {
>> return odd ? "odd" : "even";
>> }
>>
>>
>> /Gunnar Eketrapp
>>
>> 2010/9/14 John Doe <ni...@yahoo.com>
>>
>> > Yes, I could do that, but that would mean putting CSS in Java classes
and
>> I
>> > would prefer avoiding that.
>> >
>> > Does Tapestry 5 have any support for conditions like "index % 2 == 0"
in
>> > templates?
>> >
>> >
>> >
>> >
>> > ________________________________
>> > From: Stephan Windmüller <st...@tu-dortmund.de>
>> > To: users@tapestry.apache.org
>> > Sent: Tue, September 14, 2010 11:17:03 AM
>> > Subject: Re: Alternating table rows
>> >
>> > On 14.09.2010 10:01, John Doe wrote:
>> >
>> > > How can I make the alternating rows?
>> >
>> > Use the following code:
>> >
>> > private boolean switch;
>> >
>> > public String getSwitchedClass() {
>> > switch = !switch;
>> >
>> > return switch ? "odd" : "even";
>> > }
>> >
>> > And in the tml:
>> >
>> > <tr class="${switchedClass}">
>> >
>> > HTH
>> > Stephan
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> > For additional commands, e-mail: users-help@tapestry.apache.org
>> >
>> >
>> >
>> >
>>
>>
>>
>> --
>> [Hem: 08-715 59 57, Mobil: 0708-52 62 90]
>> Allévägen 2A, 132 42 Saltsjö-Boo
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>

Re: Alternating table rows

Posted by Peter Stavrinides <P....@albourne.com>.
Katia has some good advice, I am also a strong advocate for code separation, which equates to extensibility and maintanability.

Your page class (pure Java) is intended to replace JSP or any expression language, queries and any other business logic is better when moved into IoC where it is injectable and reusable. Tapestry purposefully minimizes expression language usage in pages because:
- Its hard (or near impossible) to test in templates
- It clutters the templates (error prone)
- Its better done in Java where you can debug it (that's reason enough for me)
- Its NOT clean code seperation

If you are doing any more than trivial conditional evaluation in templates then it is not clean markup. Its also good to keep your templates and page classes as minimalistic as possible so that your UI can  become pluggable if ever required. 

Cheers,
Peter


----- Original Message -----
From: "Katia Aresti Gonzalez" <ka...@gmail.com>
To: "Tapestry users" <us...@tapestry.apache.org>
Sent: Tuesday, 14 September, 2010 12:35:43 GMT +02:00 Athens, Beirut, Bucharest, Istanbul
Subject: Re: Alternating table rows

For java CSS logic reticent people :

Imagine you need more complex css logic depending not only on even/odd row,
but on the number of the elements you have in your table too, or even the
values of these elements, and depending on a pagination component too. How
will you TML look like ? like an old horrible JSP. Not only that, you won't
be able to do everything you did before to manage this kind of logic, as TML
are correct XML files.

I think that putting this kind "css logic" in the TML is just a bad idea.
This is the way to code JSP. JSP-s are not readable, they are a pain, and
separation between class and code is just not true in real world (In JSP, we
usually had to put java code to manage this kind of logic).
You will repeat yourself all over and over in your application, your code
won't be readable, neither cleaner, maintainable and you separation between
styles and just code won't be better.

Think in "odd" and "even" as identifiers, and let to your TML to add another
css class too, just as an example for your case like this :

<tr class="myClassName ${switchedClass}">

If you have a look to Tapestry Grid component source code, you will see how,
for example, the generic CSS name as "t-first" or "t-last" are applied to
the first and last row. You can add your own css class too to the grid, this
class will be rendered, so within t-first and t-last, you will be able to
overload a different style just for the first or the last row in the Grid.
MCV pattern just works perfect.


2010/9/14 Gunnar Eketrapp <gu...@gmail.com>

> Hi John! (Still alive ?)
>
> I was also frustrated about the simplicity of the template language at the
> start.
> You can't (or couldn't even) negate a test!
>
> But the philosophy of T5 is to put all logic in java ... and after using T5
> succesfully in a big rewrite of an existing site I must say that I agree
> with this.
>
> I added following utility methods in my base class ...
>
>    //
> -----------------------------------------------------------------------
>    // -- Utility methods for all our children --
>    //
> -----------------------------------------------------------------------
>
>    private boolean odd = true;
>
> public String getOddOrEvenStep() {
> odd = !odd;
> return odd ? "odd" : "even";
> }
>  public String getOddOrEvenStay() {
> return odd ? "odd" : "even";
> }
>
>
> /Gunnar Eketrapp
>
> 2010/9/14 John Doe <ni...@yahoo.com>
>
> > Yes, I could do that, but that would mean putting CSS in Java classes and
> I
> > would prefer avoiding that.
> >
> > Does Tapestry 5 have any support for conditions like "index % 2 == 0" in
> > templates?
> >
> >
> >
> >
> > ________________________________
> > From: Stephan Windmüller <st...@tu-dortmund.de>
> > To: users@tapestry.apache.org
> > Sent: Tue, September 14, 2010 11:17:03 AM
> > Subject: Re: Alternating table rows
> >
> > On 14.09.2010 10:01, John Doe wrote:
> >
> > > How can I make the alternating rows?
> >
> > Use the following code:
> >
> > private boolean switch;
> >
> > public String getSwitchedClass() {
> >    switch = !switch;
> >
> >    return switch ? "odd" : "even";
> > }
> >
> > And in the tml:
> >
> > <tr class="${switchedClass}">
> >
> > HTH
> > Stephan
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
> >
> >
>
>
>
> --
> [Hem: 08-715 59 57, Mobil: 0708-52 62 90]
> Allévägen 2A, 132 42 Saltsjö-Boo
>

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


Re: Alternating table rows

Posted by Katia Aresti Gonzalez <ka...@gmail.com>.
For java CSS logic reticent people :

Imagine you need more complex css logic depending not only on even/odd row,
but on the number of the elements you have in your table too, or even the
values of these elements, and depending on a pagination component too. How
will you TML look like ? like an old horrible JSP. Not only that, you won't
be able to do everything you did before to manage this kind of logic, as TML
are correct XML files.

I think that putting this kind "css logic" in the TML is just a bad idea.
This is the way to code JSP. JSP-s are not readable, they are a pain, and
separation between class and code is just not true in real world (In JSP, we
usually had to put java code to manage this kind of logic).
You will repeat yourself all over and over in your application, your code
won't be readable, neither cleaner, maintainable and you separation between
styles and just code won't be better.

Think in "odd" and "even" as identifiers, and let to your TML to add another
css class too, just as an example for your case like this :

<tr class="myClassName ${switchedClass}">

If you have a look to Tapestry Grid component source code, you will see how,
for example, the generic CSS name as "t-first" or "t-last" are applied to
the first and last row. You can add your own css class too to the grid, this
class will be rendered, so within t-first and t-last, you will be able to
overload a different style just for the first or the last row in the Grid.
MCV pattern just works perfect.


2010/9/14 Gunnar Eketrapp <gu...@gmail.com>

> Hi John! (Still alive ?)
>
> I was also frustrated about the simplicity of the template language at the
> start.
> You can't (or couldn't even) negate a test!
>
> But the philosophy of T5 is to put all logic in java ... and after using T5
> succesfully in a big rewrite of an existing site I must say that I agree
> with this.
>
> I added following utility methods in my base class ...
>
>    //
> -----------------------------------------------------------------------
>    // -- Utility methods for all our children --
>    //
> -----------------------------------------------------------------------
>
>    private boolean odd = true;
>
> public String getOddOrEvenStep() {
> odd = !odd;
> return odd ? "odd" : "even";
> }
>  public String getOddOrEvenStay() {
> return odd ? "odd" : "even";
> }
>
>
> /Gunnar Eketrapp
>
> 2010/9/14 John Doe <ni...@yahoo.com>
>
> > Yes, I could do that, but that would mean putting CSS in Java classes and
> I
> > would prefer avoiding that.
> >
> > Does Tapestry 5 have any support for conditions like "index % 2 == 0" in
> > templates?
> >
> >
> >
> >
> > ________________________________
> > From: Stephan Windmüller <st...@tu-dortmund.de>
> > To: users@tapestry.apache.org
> > Sent: Tue, September 14, 2010 11:17:03 AM
> > Subject: Re: Alternating table rows
> >
> > On 14.09.2010 10:01, John Doe wrote:
> >
> > > How can I make the alternating rows?
> >
> > Use the following code:
> >
> > private boolean switch;
> >
> > public String getSwitchedClass() {
> >    switch = !switch;
> >
> >    return switch ? "odd" : "even";
> > }
> >
> > And in the tml:
> >
> > <tr class="${switchedClass}">
> >
> > HTH
> > Stephan
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
> >
> >
>
>
>
> --
> [Hem: 08-715 59 57, Mobil: 0708-52 62 90]
> Allévägen 2A, 132 42 Saltsjö-Boo
>

Re: Alternating table rows

Posted by Stephan Windmüller <st...@tu-dortmund.de>.
Am 14.09.2010 10:38, schrieb Gunnar Eketrapp:

> I was also frustrated about the simplicity of the template language at the
> start.
> You can't (or couldn't even) negate a test!

What about 'negate="true"' or the "unless" component?

- Stephan

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


Re: Alternating table rows

Posted by Gunnar Eketrapp <gu...@gmail.com>.
Yea yea I said can't or couldn't negate ... I think that this negation may
have been added recently !?

Anyway put the logic in java ... and let us all try to forget about .jsp
....

2010/9/14 Thiago H. de Paula Figueiredo <th...@gmail.com>

> On Tue, 14 Sep 2010 05:38:07 -0300, Gunnar Eketrapp <
> gunnar.eketrapp@gmail.com> wrote:
>
>  Hi John! (Still alive ?)
>>
>
> Hi, guys!
>
>
>  I was also frustrated about the simplicity of the template language at the
>> start.
>>
>
> Me too. But then I discovered that templates should have the least logic on
> them, so it's way easier to test and to get the code right. If someone
> really wants to put logic in template, use the OGNL binding from
> ChenilleKit, but please, don't do that.
>
>
>  You can't (or couldn't even) negate a test!
>>
>
> You can negate a test with !: <span t:test="!loggedIn"> .... public boolean
> isLoggedIn() {...}
>
> --
> 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
>
>


-- 
[Hem: 08-715 59 57, Mobil: 0708-52 62 90]
Allévägen 2A, 132 42 Saltsjö-Boo

Re: Alternating table rows

Posted by Sven Homburg <ho...@googlemail.com>.
i totaly agree with Thiago,
implement logic into design should an absolutly no-go


with regards
Sven Homburg
Founder of the Chenille Kit Project
http://chenillekit.codehaus.org





2010/9/14 Thiago H. de Paula Figueiredo <th...@gmail.com>:
> On Tue, 14 Sep 2010 05:38:07 -0300, Gunnar Eketrapp
> <gu...@gmail.com> wrote:
>
>> Hi John! (Still alive ?)
>
> Hi, guys!
>
>> I was also frustrated about the simplicity of the template language at the
>> start.
>
> Me too. But then I discovered that templates should have the least logic on
> them, so it's way easier to test and to get the code right. If someone
> really wants to put logic in template, use the OGNL binding from
> ChenilleKit, but please, don't do that.
>
>> You can't (or couldn't even) negate a test!
>
> You can negate a test with !: <span t:test="!loggedIn"> .... public boolean
> isLoggedIn() {...}
>
> --
> 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: Alternating table rows

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 14 Sep 2010 05:38:07 -0300, Gunnar Eketrapp  
<gu...@gmail.com> wrote:

> Hi John! (Still alive ?)

Hi, guys!

> I was also frustrated about the simplicity of the template language at  
> the start.

Me too. But then I discovered that templates should have the least logic  
on them, so it's way easier to test and to get the code right. If someone  
really wants to put logic in template, use the OGNL binding from  
ChenilleKit, but please, don't do that.

> You can't (or couldn't even) negate a test!

You can negate a test with !: <span t:test="!loggedIn"> .... public  
boolean isLoggedIn() {...}

-- 
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: Alternating table rows

Posted by Gunnar Eketrapp <gu...@gmail.com>.
Hi John! (Still alive ?)

I was also frustrated about the simplicity of the template language at the
start.
You can't (or couldn't even) negate a test!

But the philosophy of T5 is to put all logic in java ... and after using T5
succesfully in a big rewrite of an existing site I must say that I agree
with this.

I added following utility methods in my base class ...

    //
-----------------------------------------------------------------------
    // -- Utility methods for all our children --
    //
-----------------------------------------------------------------------

    private boolean odd = true;

public String getOddOrEvenStep() {
odd = !odd;
return odd ? "odd" : "even";
}
 public String getOddOrEvenStay() {
return odd ? "odd" : "even";
}


/Gunnar Eketrapp

2010/9/14 John Doe <ni...@yahoo.com>

> Yes, I could do that, but that would mean putting CSS in Java classes and I
> would prefer avoiding that.
>
> Does Tapestry 5 have any support for conditions like "index % 2 == 0" in
> templates?
>
>
>
>
> ________________________________
> From: Stephan Windmüller <st...@tu-dortmund.de>
> To: users@tapestry.apache.org
> Sent: Tue, September 14, 2010 11:17:03 AM
> Subject: Re: Alternating table rows
>
> On 14.09.2010 10:01, John Doe wrote:
>
> > How can I make the alternating rows?
>
> Use the following code:
>
> private boolean switch;
>
> public String getSwitchedClass() {
>    switch = !switch;
>
>    return switch ? "odd" : "even";
> }
>
> And in the tml:
>
> <tr class="${switchedClass}">
>
> HTH
> Stephan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>
>



-- 
[Hem: 08-715 59 57, Mobil: 0708-52 62 90]
Allévägen 2A, 132 42 Saltsjö-Boo

RE: Alternating table rows

Posted by Stony Zhang <zh...@cyberobject.com.cn>.
Change code to,

public boolean isEvenColumn () {
    return index % 2 == 0;
}


<t:loop index="index" source="list" value="element">
    <t:if test="evenColumn">
        <tr class="even">
        <t:parameter name="else">
            <tr class="odd">
        </t:parameter>
    </t:if>
    </tr>
</t:loop>


Thanks
Stony


-----Original Message-----
From: John Doe [mailto:nicu4spm@yahoo.com] 
Sent: Tuesday, September 14, 2010 4:28 PM
To: Tapestry users
Subject: Re: Alternating table rows

Yes, I could do that, but that would mean putting CSS in Java classes and I 
would prefer avoiding that.

Does Tapestry 5 have any support for conditions like "index % 2 == 0" in 
templates?




________________________________
From: Stephan Windmüller <st...@tu-dortmund.de>
To: users@tapestry.apache.org
Sent: Tue, September 14, 2010 11:17:03 AM
Subject: Re: Alternating table rows

On 14.09.2010 10:01, John Doe wrote:

> How can I make the alternating rows?

Use the following code:

private boolean switch;

public String getSwitchedClass() {
    switch = !switch;

    return switch ? "odd" : "even";
}

And in the tml:

<tr class="${switchedClass}">

HTH
Stephan

---------------------------------------------------------------------
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: Alternating table rows

Posted by John Doe <ni...@yahoo.com>.
Yes, I could do that, but that would mean putting CSS in Java classes and I 
would prefer avoiding that.

Does Tapestry 5 have any support for conditions like "index % 2 == 0" in 
templates?




________________________________
From: Stephan Windmüller <st...@tu-dortmund.de>
To: users@tapestry.apache.org
Sent: Tue, September 14, 2010 11:17:03 AM
Subject: Re: Alternating table rows

On 14.09.2010 10:01, John Doe wrote:

> How can I make the alternating rows?

Use the following code:

private boolean switch;

public String getSwitchedClass() {
    switch = !switch;

    return switch ? "odd" : "even";
}

And in the tml:

<tr class="${switchedClass}">

HTH
Stephan

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


      

Re: Alternating table rows

Posted by Stephan Windmüller <st...@tu-dortmund.de>.
On 14.09.2010 10:01, John Doe wrote:

> How can I make the alternating rows?

Use the following code:

private boolean switch;

public String getSwitchedClass() {
	switch = !switch;

	return switch ? "odd" : "even";
}

And in the tml:

<tr class="${switchedClass}">

HTH
 Stephan

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