menambahkan checkbox pada grid tapestry5 | java php laravel linux mysql sql bootstrap html css query java php laravel linux mysql sql bootstrap html css query: menambahkan checkbox pada grid tapestry5

Thursday, June 16, 2011

menambahkan checkbox pada grid tapestry5

File .tml

[sourcecode language="xml"]
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd">

<t:zone t:id="zone">
<t:if test="brg">
<t:beandisplay object="brg"/>
</t:if>
</t:zone>

<t:form t:id="form">
<t:grid t:source="listbarang" t:row="barang" t:add="check" t:reorder="check">
<t:parameter name="nama_barangcell">
<t:actionlink t:id="gotodetail" t:context="${barang.id_barang}" t:zone="zone">${barang.nama_barang}</t:actionlink>
</t:parameter>

<t:parameter name="checkcell">
<t:checkbox t:id="check" t:value="check"/>
</t:parameter>
</t:grid>

</t:form>

</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.InjectComponent;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SetupRender;
import org.apache.tapestry5.corelib.components.Zone;

import com.example.tutorial.entities.Barang;

public class VariasiKomponen {

private List<Barang> listBarang;

private Barang brg;

@InjectComponent
private Zone zone;

@Property
private Barang barang;

private boolean check;

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

}

public List<Barang> getListBarang(){
listBarang = new ArrayList<Barang>();
listBarang.add(new Barang("1", "Lifebouyz", "Rp 2300"));
listBarang.add(new Barang("2", "Shinzuis", "Rp 3500"));
listBarang.add(new Barang("3", "Pepcodent", "Rp 3500"));
listBarang.add(new Barang("4", "Clearz", "Rp 7500"));
return listBarang;
}

Object onActionFromGotoDetail(String id_barang){
int i = Integer.parseInt(id_barang) - 1;
Barang b = getListBarang().get(i);
setBrg(b);
return zone.getBody();
}

public Barang getBrg() {
return brg;
}

public void setBrg(Barang brg) {
this.brg = brg;
}

public boolean isCheck() {
return check;
}

public void setCheck(boolean check) {
this.check = check;
}

}
[/sourcecode]

No comments:

Post a Comment

saifiahmada.com adalah blog belajar programming Indonesia, membahas lengkap materi bahasa pemrograman: code HTML, CSS, Bootstrap, Desain, PHP, MySQL, coding Java, Query, SQL, dan dunia linux