even odd untuk warna grid tapestry 5

code for .tml

<table t:type="grid" t:source="listBuku" t:rowsperpage="20" t:pagerPosition="top" add="del,kategori,penerbit,rak" t:reorder="del,kode_buku,judul_buku,pengarang,stok,kategori,penerbit,rak" t:row="buku" rowClass="${evenodd}" >
 <t:parameter name="judul_bukucell">
 <a t:type="actionlink" t:id="edit" t:context="${buku.id_buku}">${buku.judul_buku}</a>
 </t:parameter>
 <t:parameter name="delCell">
 <input t:type="Checkbox" t:id="delete" value="delete"/>
 </t:parameter>
 <t:parameter name="kategoricell">
 ${buku.kategori.nama_kategori}
 </t:parameter>

<t:parameter name="penerbitcell">
 ${buku.penerbit.nama_penerbit}
 </t:parameter>

<t:parameter name="rakcell">
 ${buku.rak.nama_rak}
 </t:parameter>
 </table>

code for .java :

/*

** evenodd method

*/

private int i = 0;
 public String getEvenOdd() {
 i++;
 return i % 2 == 0 ? "odd" : "even";
 }

tambahkan css script untuk row odd dan row even

 TABLE.t-data-grid TBODY TR.odd {
 background-color: #eefbb1;
 }

TABLE.t-data-grid TBODY TR.even {
 background-color: #ffffff;
 }

😀 Selesai

maven pom.xml my project

Ini adalah sebagian dependency (pom.xml) untuk project tapestry :

<dependency>
 <groupId>org.springframework</groupId>
 <artifactId>spring-web</artifactId>
 <version>2.5</version>
 </dependency>
 <dependency>
 <groupId>org.springframework</groupId>
 <artifactId>spring</artifactId>
 <version>2.5</version>
 </dependency>
 <dependency>
 <groupId>org.springframework</groupId>
 <artifactId>spring-orm</artifactId>
 <version>2.5</version>
 </dependency>

<dependency>
 <groupId>org.apache.tapestry</groupId>
 <artifactId>tapestry-spring</artifactId>
 <version>5.2.4</version>
 </dependency>

<dependency>
 <groupId>commons-dbcp</groupId>
 <artifactId>commons-dbcp</artifactId>
 <version>1.2.1</version>
 </dependency>

<dependency>
 <groupId>commons-pool</groupId>
 <artifactId>commons-pool</artifactId>
 <version>1.2</version>
 </dependency>

<dependency>
 <groupId>commons-fileupload</groupId>
 <artifactId>commons-fileupload</artifactId>
 <version>1.2.2</version>
 </dependency>

<dependency>
 <groupId>org.apache.tapestry</groupId>
 <artifactId>tapestry-upload</artifactId>
 <version>${tapestry-release-version}</version>
 </dependency>

<dependency>
 <groupId>mysql</groupId>
 <artifactId>mysql-connector-java</artifactId>
 <version>5.1.11</version>
 </dependency>

<dependency>
 <groupId>opensymphony</groupId>
 <artifactId>oscache</artifactId>
 <version>2.4</version>
 </dependency>

<dependency>
 <groupId>org.apache.tapestry</groupId>
 <artifactId>tapestry-component-report</artifactId>
 <version>5.2.4</version>
 </dependency>

<dependency>
 <groupId>com.lowagie</groupId>
 <artifactId>itext</artifactId>
 <version>2.1.0</version>
 </dependency>

<dependency>
 <groupId>org.codehaus.groovy</groupId>
 <artifactId>groovy-all</artifactId>
 <version>1.7.0</version>
 </dependency>

<dependency>
 <groupId>c3p0</groupId>
 <artifactId>c3p0</artifactId>
 <version>0.9.1.2</version>
 </dependency>

<dependency>
 <groupId>net.sourceforge.barbecue</groupId>
 <artifactId>barbecue</artifactId>
 <version>1.5-beta1</version>
 </dependency>

<dependency>
 <groupId>net.sf.jasperreports</groupId>
 <artifactId>jasperreports</artifactId>
 <version>3.7.0</version>
 </dependency>

<dependency>
 <groupId>org.apache.ibatis</groupId>
 <artifactId>ibatis-sqlmap</artifactId>
 <version>2.3.4.726</version>
 </dependency>