membuat komponen image border di tapestry | java php laravel linux mysql sql bootstrap html css query java php laravel linux mysql sql bootstrap html css query: membuat komponen image border di tapestry

Sunday, June 12, 2011

membuat komponen image border di tapestry

Untuk source ImageBorder.tml

[sourcecode language="xml"]
<!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>
[/sourcecode]

Sedangkan untuk ImageBoder.java :

[sourcecode language="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;

}
[/sourcecode]

Untuk menggunakan component ImageBorder tersebut dalam page

Buat file .tml simpan dengan nama TestComponent.tml

[sourcecode language="xml"]
<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>
[/sourcecode]

Kemudian buat file .java dengan nama TestComponent.java

[sourcecode language="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;
}
[/sourcecode]

}

The End :D





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