Class Checklist

  extended by org.apache.tapestry5.corelib.base.AbstractField
      extended by org.apache.tapestry5.corelib.components.Checklist
All Implemented Interfaces:
ClientElement, Field

public class Checklist
extends AbstractField

A list of checkboxes, allowing selection of multiple items in a list.

For an alternative component that can be used for similar purposes, see Palette.

See Also:
Form, Palette
Component Parameters
NameDescriptionTypeFlagsDefaultDefault PrefixSince
clientIdThe id used to generate a page-unique client-side identifier for the component. If a component renders multiple times, a suffix will be appended to the to id to ensure uniqueness. The uniqued value may be accessed via the clientId property.Stringprop:componentResources.idliteral
disabledIf true, then the field will render out with a disabled attribute (to turn off client-side behavior). When the form is submitted, the bound value is evaluated again and, if true, the field's value is ignored (not even validated) and the component's events are not fired.booleanfalseprop
encoderA ValueEncoder used to convert server-side objects (provided from the "source" parameter) into unique client-side strings (typically IDs) and back. Note: this component does NOT support ValueEncoders configured to be provided automatically by, Not Nullprop
labelThe user presentable label for the field. If not provided, a reasonable label is generated from the component's id, first by looking for a message key named "id-label" (substituting the component's actual id), then by converting the actual id to a presentable string (for example, "userId" to "User Id").Stringliteral
modelModel used to define the values and labels used when rendering the
selectedThe list of selected values from the org.apache.tapestry5.SelectModel. This will be updated when the form is submitted. If the value for the parameter is null, a new list will be created, otherwise the existing list will be cleared. If unbound, defaults to a property of the container matching this component's
validateThe object that will perform input validation. The validate binding prefix is generally used to provide this object in a declarative

For this example, we'll implement a page from an e-commerce order wizard; the page collects information about special handling for the order:

Now let's see how the component can be used.

public enum SpecialHandling

In this contrived example, the possible types of special handling are defined using an enum. It's more likely, in the real world, that this would be defined in terms of a database entity.


<html xmlns:t="">
        <h1>Special Handling</h1>


            <t:checklist t:id="handling" encoder="encoder" model="model"/>


            <input type="submit" value="Continue"/>



Here we are able to omit the selected parameter (the list of selected items) because the Checklist component's id matches a property of the page.

The model parameter will define the available options that can be selected. The encoder parameter will define how to translate server side values (the enum values) into client side strings and back.

public class OrderHandling {
    private List<SpecialHandling> handling;

    private Messages messages;

    public ValueEncoder getEncoder() {
        return new EnumValueEncoder(SpecialHandling.class);

    public SelectModel getModel() {
        return new EnumSelectModel(SpecialHandling.class, messages);

Tapestry has built-in public classes that help convert enum types into value encoders and select models.

Injecting a Messages object gives a component access to its own message catalog.

The Checklist component will read the handling property when rendering (it's ok for it to be null). When the form is submitted, it will create a new List and update the handling property.


The Checklist component can be customized through CSS. Following CSS rules are used:

Each checkbox and its label is enclosed by a div element whose css attribute is set to t-checklist-row.

Constructor Summary
Method Summary
 boolean isRequired()
          Returns false; most components do not support declarative validation.
protected  void processSubmission(String controlName)
          Method implemented by subclasses to actually do the work of processing the submission of the form.
Methods inherited from class org.apache.tapestry5.corelib.base.AbstractField
decorateInsideField, getClientId, getControlName, getLabel, isDisabled, putPropertyNameIntoBeanValidationContext, removePropertyNameFromBeanValidationContext, setDecorator, setFormSupport
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public Checklist()
Method Detail


protected void processSubmission(String controlName)
Description copied from class: AbstractField
Method implemented by subclasses to actually do the work of processing the submission of the form. The element's controlName property will already have been set. This method is only invoked if the field is not disabled.

Specified by:
processSubmission in class AbstractField
controlName - the control name of the rendered element (used to find the correct parameter in the request)


public boolean isRequired()
Description copied from class: AbstractField
Returns false; most components do not support declarative validation.

Specified by:
isRequired in interface Field
isRequired in class AbstractField
true if a non-blank value is required for the field

Copyright © 2003-2012 The Apache Software Foundation.