All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.tapestry5.corelib.components.BeanDisplay.xdoc Maven / Gradle / Ivy

Go to download

Central module for Tapestry, containing interfaces to the Java Servlet API and all core services and components.

There is a newer version: 5.8.6
Show newest version

    

        

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:

The @NonVisual annotation prevents the id property from being displayed.

Presumably, some other page is obtaining the User instance and invoking the setUser() method.

View User

${bean.lastname.toUpperCase()} ]]>

The ]]> 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:

]]>

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 ]]> 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.





© 2015 - 2024 Weber Informatics LLC | Privacy Policy