You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Gunter D'Hondt <gu...@sofico.be> on 2005/10/13 09:26:19 UTC
repeaters & alternate row colours
In my form template I'd like to have alternate colours on the repeater
rows so that the output is something like
<tr id="row1">...</tr>
<tr id="row2">...</tr>
<tr id="row1">...</tr>
...
does anybody have an idea how I can do this? below the snippet of my form
template
<wt:repeater-size id="options" />
<table>
<wt:repeater-widget id="options">
<tr>
<td><wt:widget
id="description"/></td>
</tr>
</wt:repeater-widget>
</table>
is there a method of retrieving the repeater row-id?
thanks in advance,
Gunter
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: repeaters & alternate row colours
Posted by Bertrand Delacretaz <bd...@apache.org>.
Le 13 oct. 05, à 10:02, Gunter D'Hondt a écrit :
> as Jorg also mentoined; I'm still using 2.1.4 (and cannot upgrade that
> quickly) so as far as I know I can't use the jx macros in that version
> any other possibilities?
you can post-process your form with an XSLT transform, and inject
attributes on even/odd rows:
<xsl:template match="tr[position() mod 2 != 0]">
...copy element and add required attributes
</xsl:template>
-Bertrand
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
[Solved] Re: repeaters & alternate row colours
Posted by Gunter D'Hondt <gu...@sofico.be>.
Yep, thanks for the xslt code snippet!
Only a few adjustments so that the tbody is not necessary and the rest of
the html is copied again:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="table/@alternate" />
<xsl:template match="table[@alternate ='true']">
<table>
<xsl:copy-of select="@*"/>
<xsl:apply-templates select="tr" mode="alternate"/>
</table>
</xsl:template>
<xsl:template match="tr" mode="alternate">
<xsl:copy>
<xsl:apply-templates select="@*" />
<xsl:attribute name="class">
<xsl:choose>
<xsl:when
test="position() mod 2 = 1">
<xsl:text>GridRowOdd</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>GridRowEven</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:apply-templates select="node() | @*"
/>
</xsl:copy>
</xsl:template>
<xsl:template match="@*|node()" priority="-1">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Regards,
Gunter
Mark Lundquist <ml...@wrinkledog.com>
13/10/2005 10:07
Please respond to
users@cocoon.apache.org
To
users@cocoon.apache.org
cc
Subject
FW_SPAM: Re: repeaters & alternate row colours
On Oct 13, 2005, at 1:02 AM, Gunter D'Hondt wrote:
> as Jorg also mentoined; I'm still using 2.1.4 (and cannot upgrade that
> quickly) so as far as I know I can't use the jx macros in that version
> any other possibilities?
Sure. I use XSLT for this, that way I can get this effect for any
table I want, not just repeaters.
E.g.,
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="table/@alternate" />
<xsl:template match="table[@alternate ='true']/tbody">
<tbody>
<xsl:apply-templates select="tr"
mode="alternate"/>
</tbody>
</xsl:template>
<xsl:template match="tr" mode="alternate">
<xsl:copy>
<xsl:apply-templates select="@*" />
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="position() mod
2 = 1">
<xsl:text>odd</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>even</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:apply-templates select="node() | @*" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
HTH,
—ml—
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: repeaters & alternate row colours
Posted by Mark Lundquist <ml...@wrinkledog.com>.
On Oct 13, 2005, at 1:02 AM, Gunter D'Hondt wrote:
> as Jorg also mentoined; I'm still using 2.1.4 (and cannot upgrade that
> quickly) so as far as I know I can't use the jx macros in that version
> any other possibilities?
Sure. I use XSLT for this, that way I can get this effect for any
table I want, not just repeaters.
E.g.,
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="table/@alternate" />
<xsl:template match="table[@alternate ='true']/tbody">
<tbody>
<xsl:apply-templates select="tr"
mode="alternate"/>
</tbody>
</xsl:template>
<xsl:template match="tr" mode="alternate">
<xsl:copy>
<xsl:apply-templates select="@*" />
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="position() mod
2 = 1">
<xsl:text>odd</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>even</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:apply-templates select="node() | @*" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
HTH,
—ml—
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: repeaters & alternate row colours
Posted by Gunter D'Hondt <gu...@sofico.be>.
as Jorg also mentoined; I'm still using 2.1.4 (and cannot upgrade that
quickly) so as far as I know I can't use the jx macros in that version
any other possibilities?
thnx,
Gunter
Christoph Hermann <ch...@guschtel.de>
13/10/2005 09:35
Please respond to
users@cocoon.apache.org
To
users@cocoon.apache.org
cc
Subject
Re: repeaters & alternate row colours
Gunter D'Hondt schrieb:
Hello,
> In my form template I'd like to have alternate colours on the repeater
> rows so that the output is something like
> <tr id="row1">...</tr>
> <tr id="row2">...</tr>
> <tr id="row1">...</tr>
> ...
Use the JX Macros to do this:
<jx:import
uri="resource://org/apache/cocoon/forms/generation/jx-macros.xml"/>
...
<jx:choose>
<jx:when test="${repeaterLoop.index % 2 == 0}">
<!-- i'm not sure about the %2 == 0
Syntax, but it should get you
going -->
...
</jx:when>
<jx:otherwise>
</jx:otherwise>
</jx:choose>
HTH
Christoph
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: repeaters & alternate row colours
Posted by Christoph Hermann <ch...@guschtel.de>.
Gunter D'Hondt schrieb:
Hello,
> In my form template I'd like to have alternate colours on the repeater
> rows so that the output is something like
> <tr id="row1">...</tr>
> <tr id="row2">...</tr>
> <tr id="row1">...</tr>
> ...
Use the JX Macros to do this:
<jx:import
uri="resource://org/apache/cocoon/forms/generation/jx-macros.xml"/>
...
<jx:choose>
<jx:when test="${repeaterLoop.index % 2 == 0}">
<!-- i'm not sure about the %2 == 0 Syntax, but it should get you
going -->
...
</jx:when>
<jx:otherwise>
</jx:otherwise>
</jx:choose>
HTH
Christoph
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: repeaters & alternate row colours
Posted by Jorg Heymans <jh...@domek.be>.
Gunter D'Hondt wrote:
> <wt:repeater-size id="options" />
are you still using woody ? If you are in a position to upgrade then the
jx form macros can help you out here.
Jorg
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org