Used to display the properties of a bean, using an underlying BeanModel. The output definition list: a dl element containing a series of dt/dd pairs. The property label is used as the dt and the property value (formatted as per the datatype) is the dd. Only properties that have a known data type are displayed. The property id is used as the class attribute of the dt and dd element, allowing CSS customization per property. This does not occur when lean is bound to true. The outer dl element has the CSS class "t-beandisplay".
| Name | Type | Flags | Default | Default Prefix | Description |
|---|---|---|---|---|---|
| add | String | NOT Allow Null | literal | A comma-separated list of property names to be added to the BeanModel. | |
| exclude | String | NOT Allow Null | literal | A comma-separated list of property names to be removed from the BeanModel. The names are case-insensitive. | |
| include | String | NOT Allow Null | literal | A comma-separated list of property names to be retained from the BeanModel. Only these properties will be retained, and the properties will also be reordered. The names are case-insensitive. | |
| lean | boolean | NOT Allow Null | false | prop | If true, then the CSS class attribute on the dt and dd elements will be ommitted. |
| model | BeanModel | NOT Allow Null | prop | The model that identifies the parameters to be displayed, their order, and every other aspect. If not specified, a default bean model will be created from the type of the object bound to the object parameter. | |
| object | Object | Required, NOT Allow Null | prop | The object to be rendered; if not explicitly bound, a default binding to a property whose name matches this component's id will be used. | |
| overrides | ComponentResources | NOT Allow Null | componentResources | prop | Where to search for local overrides of property display blocks as block parameters. Further, the container of the overrides is used as the source for overridden validation messages. This is normally the component itself, but when the component is used within a BeanEditForm, it will be the BeanEditForm's block parameter that will be searched. |
| reorder | String | NOT Allow Null | literal | A comma-separated list of property names indicating the order in which the properties should be presented. The names are case insensitive. Any properties not indicated in the list will be appended to the end of the display order. |
Informal parameters: supported
public class User
{
@NonVisual
private long id;
private String firstName;
private String lastName;
private int age;
public long getId() { return id; }
public void setId(long id) { this.id = id; }
public String getFirstName() { return firstName; }
public void setFirstName(String firstName) { this.firstName = firstName; }
public String getLastName() { return lastName; }
public void setLastName(String lastName) { this.lastName = lastName; }
public int getAge() { return age; }
public void setAge(int age) { this.age = age; }
}The @NonVisual annotation prevents the id property from being displayed.
public class ViewUser
{
@Persist
private User user;
public User getUser()
{
return user;
}
public void setUser(User user)
{
this.user = user;
}
}Presumably, some other page is obtaining the User instance and invoking the setUser() method.
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd" xmlns:p="tapestry:parameter">
<body>
<h1>View User</h1>
<t:beandisplay object="user">
<p:lastName>
${bean.lastname.toUpperCase()}
</p:lastName>
</t:beandisplay>
</body>
</html>
The
<p:lastName>
element is an
override
for the property. The name is
matched against a property of the bean.
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").
The content is rendered as a <dl> (definition list) element, containing <dt> (term) and <dd> (definition) elements.
The <dt> will have the CSS class "t-beandisplay".
The <dt> and <dd> elements will have the property id as the CSS class name (i.e., "firstName", "lastName", etc.). This allows individual properties of the bean to have specific CSS rules applied.
The ":" after the property label is supplied via CSS.
You can re-order the properties using the reorder parameter:
<t:beandisplay object="user" reorder="lastname,firstname"/>
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.
You can also remove properties with the exclude parameter, which is equivalent to the @NonVisual annotation.
You might find
<t:beandisplay object="this"/>
useful on occasion. It will display all the properties of the current page.
As with the BeanEditForm component, you may override the labels displayed for the fields using the page's message catalog.
Please refer to the PageLink component documentation for an alternate way to manage the user field.