membuat layout sebagai komponen template tapestry5

File-file yang akan dibuat :

Cetakan.tml, Cetakan.java, cetakan.css

monggo cak😀

Cetakan.tml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
 xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"
 xmlns:p="tapestry:parameter">
 <head>
 <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
 <title>${title}</title>
 </head>
 <body>
 <div id="header">
 <center><h3>Belajar Tapestry 5</h3></center>
 </div>
 <div id="page">

<div id="kiri">
 <ul><t:pagelink page="master/mahasiswa">Master Mahasiswa</t:pagelink></ul>
 <ul><t:pagelink page="master/pasien">Master Pasien</t:pagelink></ul>
 </div>
 <div id="content"><fieldset><t:body/></fieldset></div>

</div>
 </body>
 </html>

File Cetakan.java

package com.example.tutorial.components;

import org.apache.tapestry5.BindingConstants;
 import org.apache.tapestry5.annotations.IncludeStylesheet;
 import org.apache.tapestry5.annotations.Parameter;
 import org.apache.tapestry5.annotations.Property;

@IncludeStylesheet("context:layout/cetakan.css")
 public class Cetakan {

@SuppressWarnings("unused")
 @Property
 @Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)
 private String title;

}

File cetakan.css

body {

margin: 0;
 padding: 0;
 background: #FFFFFF url( images/img21.jpg ) repeat-x;
 text-align: justify;
 font-family: Arial, Helvetica, sans-serif;
 font-size: 12px;
 color: #626262;
 }
 input {
 padding: 2px;
 /*background: #FEFEFE url( images/img13.gif ) repeat-x;
 */
 border: 1px solid #b3d515;
 font: normal 1em Arial, Helvetica, sans-serif;
 }

select{
 border:1px;
 border-style:solid;
 border-color:#b3d515;
 }

textarea{
 border: 1px solid #b3d515;
 font-family: Arial, Helvetica, sans-serif;
 font-size: 12px;
 }

.button {
 border: 1px solid #000000;
 padding: 2px 2px 2px 2px;
 margin-left : 2px;
 margin-right: 2px;
 font-family: Arial, Helvetica, sans-serif;
 font-size: 12px;
 background: #b3d515 url( images/backbutton.jpg ) repeat-x;
 }

fieldset {
 color: #000000;
 border: 1px solid #b3d515;
 font-family: Arial, Helvetica, sans-serif;
 font-size: 12px;
 }

h3 {
 color : #ffffff;
 }

table {
 cellspacing : 0;
 cellpadding : 0;
 font-family: Arial, Helvetica, sans-serif;
 font-size: 12px;
 }

#header {
 height : 50px;
 }

#page{
 width : 1250px;
 }

#kiri {
 width : 200px;
 float : left;
 margin : 0px 0px 0px 0px;
 padding: 0px 0px 0px 0px;

}

.menu {
 display : block;
 background : #b3d515;
 height : 23px;
 width : 200px;
 }

#content {
 margin-left : 0px;
 padding-left : 5px;
 width : 1000px;
 float : left;
 }

#kanan {
 width : 150px;
 float:left;
 }

.sidebar ul {

margin: 1px 0px 1px 4px;
 padding: 0px 0px 0px 0px;

}

.sidebar a {
 display: block;
 height : 25px;
 width : 180px;
 color : #000000;
 text-decoration: none;
 font-weight: bold;
 background: #b3d515;
 /*padding : 5px 0px 0px 10px;*/
 padding : 5px 0px 0px 10px;
 }

.sidebar a:hover {
 color : #ffffff;
 font-weight: bold;
 text-decoration: none;
 background: #ffcc00;
 }

/*data grid customize*/

DIV.t-data-grid {
 font-family: Arial, Helvetica, sans-serif;
 margin-top:20px;
 margin-bottom:20px;
 }

DIV.t-data-grid-pager {
 margin: 8px 0px;
 }

DIV.t-data-grid-pager A, DIV.t-data-grid-pager SPAN.current {
 text-decoration: none;
 color: black;
 padding: 2px 5px;
 font-size: 11px;
 border: 1px solid #b3d515;
 margin-right: 5px;
 }

DIV.t-data-grid-pager A:hover {
 border: 1px solid black;
 }

DIV.t-data-grid-pager SPAN.current {
 color: white;
 border: 1px solid #000066;
 background-color: #b3d515;
 }

TABLE.t-data-grid {
 border-collapse: collapse;
 border-left: 1px solid #000066;
 border-top: 1px solid #000066;
 background-color: #000066;
 font-size: 12px;
 }

table.t-data-grid thead {
 border-top: 1px solid #b3d515; /* For Firefox */
 }

TABLE.t-data-grid THEAD TR {
 color: white;
 background-color: #ffffff;
 }

TABLE.t-data-grid THEAD TR TH {
 text-align: left;
 padding: 1px 3px;
 white-space: nowrap;
 border-left: 1px solid #b3d515;
 border-right: 1px solid #b3d515;
 border-bottom: 1px solid #b3d515;
 background-color:#b3d515;
 /*width: 150px;*/
 }

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

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

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

TABLE.t-data-grid TBODY TR TH A {
 color: white;
 }

TABLE.t-data-grid TBODY TR TD {
 border-right: 1px solid #b3d515;
 border-left: 1px solid #b3d515;
 border-bottom: 1px solid #b3d515;
 padding: 1px 3px;
 }

untuk menggunakan komponen layout ini :

buat file MasterPegawai.tml

<html     t:type="cetakan" title="Master Pegawai"
 xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd">

<fieldset><legend>Master Pegawai</legend>
 <t:beaneditform t:id="pegawai" object="pegawai"/>
 </fieldset>

</html>

dan file MasterPegawai.java

package com.example.tutorial.pages.master;

import org.apache.tapestry5.annotations.Property;
 import org.apache.tapestry5.annotations.SetupRender;

import com.example.tutorial.entities.Pegawai;

public class MasterPegawai {

@Property
 private Pegawai pegawai;

@SetupRender
 void setupRender(){
 if (pegawai == null) pegawai = new Pegawai();
 }

}

dan HASILNYA adalah “bim salabimmmm”

File tambahan (Pegawai.java)

package com.example.tutorial.entities;

import java.io.Serializable;

public class Pegawai implements Serializable {

private String id_pegawai;

private String nama_pegawai;

private String alamat;

private String nip;

private java.util.Date tgl_lahir;

private String tempat_lahir;

private Golongan golongan;

public String getId_pegawai() {
 return id_pegawai;
 }

public void setId_pegawai(String id_pegawai) {
 this.id_pegawai = id_pegawai;
 }

public String getNama_pegawai() {
 return nama_pegawai;
 }

public void setNama_pegawai(String nama_pegawai) {
 this.nama_pegawai = nama_pegawai;
 }

public String getAlamat() {
 return alamat;
 }

public void setAlamat(String alamat) {
 this.alamat = alamat;
 }

public String getNip() {
 return nip;
 }

public void setNip(String nip) {
 this.nip = nip;
 }

public java.util.Date getTgl_lahir() {
 return tgl_lahir;
 }

public void setTgl_lahir(java.util.Date tgl_lahir) {
 this.tgl_lahir = tgl_lahir;
 }

public String getTempat_lahir() {
 return tempat_lahir;
 }

public void setTempat_lahir(String tempat_lahir) {
 this.tempat_lahir = tempat_lahir;
 }

public Golongan getGolongan() {
 return golongan;
 }

public void setGolongan(Golongan golongan) {
 this.golongan = golongan;
 }

@Override
 public String toString() {
 StringBuffer sb = new StringBuffer();
 sb.append("ID Pegawai : "+id_pegawai);
 sb.append("Nama Pegawai : "+nama_pegawai);
 sb.append("Alamat : "+alamat);
 return sb.toString();
 }

}

File Golongan.java

package com.example.tutorial.entities;

public enum Golongan {
 I, II, IIIA, IIIB, IIIC, IVA, IVB, IVC, IVD
 }

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