how about
Java:
public String getRowClass() {
return (index % 2 == 0) ? "evenRow" : "oddRow";
}
tml:
<t:loop t:source="selectedModule.settings" t:value="currentSetting"
t:index="index">
...
<tr class="${rowClass}">
css:
.oddRow {
background: etc...
}
.evenRow {
background: etc....
}
On Jul 4, 2012, at 4:04 PM, bhorvat wrote:
> So here is the annoying problem, I have a loop and I need to make every even
> rows different then odd rows. So the way I do this is I have a index and a
> methods isEvenRow that returns if the row is even. Then based on that I have
> one if withe else section. The only difference between content of both is in
> one single tiny class called itrEven.
>
> <t:loop t:source="selectedModule.settings" t:value="currentSetting"
> t:index="index">
> <t:if test="evenRow">
> <div class="itRow <b>itrEven*"></div>
> <p:else>
> <div class="itRow"></div>
> </p:else>
> </t:if>
> </t:loop>
>
> So how do I make this less verbose. I dont like the fact that I need to have
> one extra field and methos in the page, as well as having the duplication of
> the html code (there is a lot of code in between if else section I have just
> removed it since it is not important)
>
> Is there a better solution?
>
> And yes I know that I am being pedantic about this, but it is really
> annoying :)
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/How-to-have-every-second-value-in-the-t-loop-different-tp5714278.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]