| <document> |
| <body> |
| |
| <section name="Related Components"> |
| |
| <ul> |
| <li> |
| <a href="BeanEditForm.html">BeanEditForm</a> |
| </li> |
| <li> |
| <a href="Grid.html">Grid</a> |
| </li> |
| </ul> |
| |
| </section> |
| |
| <section name="Examples"> |
| |
| <p> |
| Here, we'll display a User object, consisting |
| of a first name, last name and age. We'll also customize the output of the last name property, to |
| display the name in all upper-case. The result: |
| </p> |
| |
| <p> |
| <img src="beandisplay_ref.png"/> |
| </p> |
| |
| <subsection name="User.java"> |
| <source><![CDATA[ |
| public class User |
| { |
| private long _id; |
| |
| private String _firstName; |
| |
| private String _lastName; |
| |
| private int _age; |
| |
| public long getId() { return _id; } |
| |
| @NonVisual |
| public void setId(long id) { _id = id; } |
| |
| public String getFirstName() { return _firstName; } |
| |
| public void setFirstName(String firstName) { _firstName = firstName; } |
| |
| public String getLastName() { return _lastName; } |
| |
| public void setLastName(String lastName) { _lastName = lastName; } |
| |
| public int getAge() { return _age; } |
| |
| public void setAge(int age) { _age = age; } |
| }]]></source> |
| |
| <p>The @NonVisual annotation prevents the id property from being displayed.</p> |
| |
| </subsection> |
| |
| <subsection name="ViewUser.java"> |
| <source><![CDATA[ |
| public class ViewUser |
| { |
| @Persist |
| private User _user; |
| |
| public User getUser() |
| { |
| return _user; |
| } |
| |
| public void setUser(User user) |
| { |
| _user = user; |
| } |
| }]]></source> |
| |
| <p> |
| Presumably, some other page is obtaining the User instance and invoking the setUser() method. |
| </p> |
| |
| </subsection> |
| |
| |
| <subsection name="ViewUser.tml"> |
| <source><![CDATA[ |
| <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"> |
| <body> |
| <h1>View User</h1> |
| |
| <t:beandisplay object="user"> |
| <t:parameter name="lastname"> |
| ${bean.lastname.toUpperCase()} |
| </t:parameter> |
| </t:beandisplay> |
| </body> |
| </html> |
| ]]></source> |
| |
| <p> |
| The |
| <code><![CDATA[<t:parameter>]]></code> |
| element is an |
| <em>override</em> |
| for the property. The name is |
| matched against a property of the bean. |
| </p> |
| |
| <p> |
| Here we are leveraging the ability to invoke methods as part of a property expression. |
| We are also highlighting Tapestry's case insensitivity ("lastname" vs. "lastName"). |
| </p> |
| |
| </subsection> |
| </section> |
| |
| <section name="Notes"> |
| |
| <p> |
| You can re-order the properties using the reorder parameter: |
| </p> |
| |
| <source><![CDATA[<t:beandisplay object="user" reorder="lastname,firstname"/>]]></source> |
| |
| <p> |
| You can accomplish the same thing by changing the order of the |
| getter methods in the bean class. The default order for properties is not alphabetical, |
| it is the order of the getter methods. |
| </p> |
| |
| |
| <p> |
| You can also remove properties with the exclude parameter, which is equivalent to the |
| @NonVisual annotation. |
| </p> |
| |
| <p> |
| You might find |
| <code><![CDATA[<t:beandisplay object="this"/>]]></code> |
| useful on occasion. It will display all the properties of the current page. |
| </p> |
| |
| <p> |
| As with the |
| <a href="BeanEditForm.html">BeanEditForm</a> |
| component, |
| you may override the labels displayed for the fields using |
| the page's message catalog. |
| </p> |
| |
| <p> |
| Please refer to the |
| <a href="PageLink.html">PageLink</a> |
| component documentation for an alternate way to manage the _user field. |
| </p> |
| |
| </section> |
| |
| </body> |
| </document> |