menjajal komponen loop tapestry5

File .tml

<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd">

<table>
 <thead bgcolor="#cccccc">
 <tr>
 <th>Id Barang</th>
 <th>Nama Barang</th>
 <th>Harga Barang</th>
 </tr>
 </thead>
 <tbody>
 <tr t:type="Loop" t:source="barangs" t:value="barang" bgcolor="#ffcc00">
 <td>${barang.id_barang}</td>
 <td>${barang.nama_barang}</td>
 <td>${barang.harga_barang}</td>
 </tr>
 </tbody>
 </table>

</html>

File .java

package com.example.tutorial.pages;

import java.util.ArrayList;
 import java.util.List;

import org.apache.tapestry5.annotations.Property;
 import org.apache.tapestry5.annotations.SetupRender;
 import com.example.tutorial.entities.Barang;

public class Tloop {

private List<Barang> barangs;

@Property
 private Barang barang;

@SetupRender
 void setupRender(){
 barang = new Barang();
 }

public List<Barang> getBarangs(){
 barangs = new ArrayList<Barang>();
 barangs.add(new Barang("01", "Barang A", "5000"));
 barangs.add(new Barang("02", "Barang B", "4000"));
 barangs.add(new Barang("03", "Barang C", "6000"));
 return barangs;
 }
 }

Published by

saifiahmada

Begin a big Process with a bit trying

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s