[sourcecode language="xml"]
<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>
[/sourcecode]
File .java
[sourcecode language="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;
}
}
[/sourcecode]
No comments:
Post a Comment