Searching...
Wednesday, 19 September 2012

Tapestry BeanDisplay Example

23:02

BeanDisplay

BeanDisplay is part of tapestry core library and it used to display the properties of a bean. In the previous two posts we saw how to create the projects ,templates and pages. Let us see the BeanDisplay how it is working

BeanDisplay Example
1. Create the template (BeanDisplay.tml)
<html t:type="layout"title="TestArtifact Page"
        xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"
      xmlns:p="tapestry:parameter">
<body>
Vinod: Bean display example
<t:beandisplayobject="person">
</t:beandisplay>
</body>
</html>
2. Create model class
package vinod.test.model;
public class Person {
private String name;
private String address;
private String country;

public Person(String name, String address, String country) {
super();
this.name = name;
this.address = address;
this.country = country;
}

public String getName() {
return this.name;
}

public void setName(String name) {
this.name = name;
}

public String getAddress() {
return this.address;
}

public void setAddress(String address) {
this.address = address;
}

public String getCountry() {
return this.country;
}

public void setCountry(String country) {
this.country = country;
}

}
Create java class for the template
package vinod.test.pages;

import vinod.test.model.Person;

public class BeanDisplay {

Person person = new Person("vinod", "Bangalore", "India");

public Person getPerson() {
return this.person;
}

public void setPerson(Person person) {
this.person = person;
}

}
Run the application and see the output

Reference 

0 comments: