inject service dao tapestry5

Buat Tabel di mysql:

 create table laptop
 id_laptop varchar(15) primary key not null,
 label varchar(30) not null,
 merk varchar(30),
 cpu varchar(30),
 memory varchar(30),
 speed varchar(30),
 harddisk varchar(30),
 webcam varchar(30)

Buat bean Laptop:

 package com.ipi.mysms.beans;

import org.apache.tapestry5.beaneditor.NonVisual;

public class Laptop {

 private String id_laptop;

private String label;

private String merk;

private String cpu;

private String memory;

private String speed;

private String harddisk;

private String webcam;

public String getId_laptop() {
 return id_laptop;

public void setId_laptop(String id_laptop) {
 this.id_laptop = id_laptop;

public String getLabel() {
 return label;

public void setLabel(String label) {
 this.label = label;

public String getMerk() {
 return merk;

public void setMerk(String merk) {
 this.merk = merk;

public String getCpu() {
 return cpu;

public void setCpu(String cpu) {
 this.cpu = cpu;

public String getMemory() {
 return memory;

public void setMemory(String memory) {
 this.memory = memory;

public String getSpeed() {
 return speed;

public void setSpeed(String speed) {
 this.speed = speed;

public String getHarddisk() {
 return harddisk;

public void setHarddisk(String harddisk) {
 this.harddisk = harddisk;

public String getWebcam() {
 return webcam;

public void setWebcam(String webcam) { = webcam;


buat interface

 package com.ipi.mysms.dao;

import java.util.List;

import com.ipi.mysms.beans.Laptop;

public interface LaptopDao {

public void insert(Laptop laptop);

public void update(Laptop laptop);

public void delete(Laptop laptop);

public List<Laptop> getAllLaptop();

public Laptop findByPrimaryKey(String id_laptop);


buat class

 package com.ipi.mysms.daoimpl;

import java.util.List;


import com.ipi.mysms.beans.Laptop;
 import com.ipi.mysms.dao.LaptopDao;

public class LaptopDaoImpl extends SqlMapClientDaoSupport implements LaptopDao {

public void insert(Laptop laptop) {
 getSqlMapClientTemplate().insert("Laptop.insert", laptop);

public void update(Laptop laptop) {
 getSqlMapClientTemplate().update("Laptop.update", laptop);

public void delete(Laptop laptop) {
 getSqlMapClientTemplate().delete("Laptop.delete", laptop);

public List<Laptop> getAllLaptop() {
 return getSqlMapClientTemplate().queryForList("Laptop.getAllLaptop");

public Laptop findByPrimaryKey(String id_laptop) {
 return (Laptop) getSqlMapClientTemplate().queryForObject("Laptop.findByPrimaryKey", id_laptop);


tambahkan setting untuk inject service dao

public static void bind(ServiceBinder binder)
 binder.bind(LaptopDao.class, LaptopDaoImpl.class);

buat MasterLaptop.tml

 <html t:type="cetakan" title="Master Contact"

 <fieldset><legend>Master Laptop</legend>

 <t:beaneditor t:id="laptop" t:object="laptop">


 <t:submit t:id="save" t:value="Save/Update"/>
 <t:submit t:id="reset" t:value="Reset"/>
 <t:submit t:id="search" t:value="Search"/>
 <t:submit t:id="delete" t:value="Delete"/>

<t:grid source="listlaptop" row="laptoprow" add="del" reorder="del" rowsperpage="6" rowClass="${evenodd}" pagerPotition="top">
 <t:parameter name="delcell">
 <t:checkbox t:id="del" t:value="del"/>
 <t:parameter name="labelcell">
 <t:actionlink t:id="edit" context="laptoprow.id_laptop">${laptoprow.label}</t:actionlink>



 package com.ipi.mysms.pages.master;

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

import org.apache.tapestry5.annotations.Persist;
 import org.apache.tapestry5.annotations.Property;
 import org.apache.tapestry5.ioc.annotations.Inject;

import com.ipi.mysms.beans.Laptop;
 import com.ipi.mysms.dao.LaptopDao;
 import com.ipi.mysms.facade.MasterFacade;
 import com.ipi.mysms.util.Generate;

public class MasterLaptop {

 private LaptopDao laptopDao;

 private MasterFacade masterFacate;

 private Laptop laptop;

 private Laptop laptoprow;

private List<Laptop> listLaptop;

private boolean del;

private List<Laptop> listDelete;

void clear(){
 laptop = new Laptop();

void onSelectedFromSave(){

if (getLaptop().getId_laptop() == null){

void onSelectedFromReset(){

void onSelectedFromDelete(){
 for (Laptop l : getListDelete()){

void onSelecetedFromSearch(){


void onActionFromEdit(String id_laptop){
 Laptop l = laptopDao.findByPrimaryKey(id_laptop);

public List<Laptop> getListLaptop(){
 if (listLaptop == null) listLaptop = new ArrayList<Laptop>();
 return laptopDao.getAllLaptop();

public Laptop getLaptop() {
 if (laptop == null) laptop = new Laptop();
 return laptop;

public void setLaptop(Laptop laptop) {
 this.laptop = laptop;

public boolean isDel() {
 return del;

public void setDel(boolean del) {
 if (del){

public List<Laptop> getListDelete() {
 if (listDelete == null) listDelete = new ArrayList<Laptop>();
 return listDelete;

public void setListDelete(List<Laptop> listDelete) {
 this.listDelete = listDelete;

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

minum kopi klo udah selesai😀

sambil nunggu jetty running di server😀

Published by


Begin a big Process with a bit trying

One thought on “inject service dao tapestry5”

  1. Excellent sharing knowledge, could you kindly share some of XML configuration as well as download source code.

Leave a Reply

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

You are commenting using your 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