org.apache.tapestry5.corelib.components.Radio.xdoc Maven / Gradle / Ivy
Show all versions of tapestry-core Show documentation
Radio components are always used in conjunction with
a RadioGroup component. The RadioGroup defines the property
that will be read and updated, and the individual Radio
components determine what value will be assigned to the property.
Our example will be part of a page that collects credit card information.
We'll just be showing the portions related to
a set of radio buttons for choosing the type of credit card.
The advantage of using radio buttons here, rather than a drop down list,
is that we could extend the labels to use a small image of each
type of supported card.
We're once again using the trick of matching the component's id
to a property of the containing page. The RadioGroup's value parameter
will be bound to the page's type property. Likewise, each of the
Radio components will be matched to a property of the page.
We use a number of read-only properties to provide
each Radio component with its corresponding enum value, that will
ultimately be assigned to the page's type property
(if that corresponding Radio component is selected by the user).
This is far from the only pattern of usage; it is much more likely
that you will use a Loop component around a single Radio component
than you will use a whole array of Radio components as in this example.
We override the default generated labels for a few fields and enum values: