membuat komponen image border di tapestry

Untuk source ImageBorder.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">

<img src="${imageurl}" width="${width}" height="${height}" style="border: 2px #b3d515 solid;" />
 </html>

Sedangkan untuk ImageBoder.java :

 package com.ipi.myweb.components;

/*
 * saifiahmada.co.nr
 */

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

public class ImageBorder {

@SuppressWarnings("unused")
 @Parameter(required = true)
 @Property
 private String imageUrl;

@SuppressWarnings("unused")
 @Parameter
 @Property
 private int width;

@SuppressWarnings("unused")
 @Parameter
 @Property
 private int height;

}

Untuk menggunakan component ImageBorder tersebut dalam page

Buat file .tml simpan dengan nama TestComponent.tml

<html t:type="layout2" title="Test Component"
 xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"
 xmlns:p="tapestry:parameter">

<p>Test Component</p>

<t:imageborder imageurl="${image}" width="110" height="150" />

</html>

Kemudian buat file .java dengan nama TestComponent.java

package com.ipi.myweb.pages;

import com.ipi.myweb.annotation.ProtectedPage;

@ProtectedPage
 public class TestComponent {

private final static String url = "/Images/331.jpg";

public String getImage(){
 return url;
 }

}

The End😀

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