JSF 1.1 Checkbox Component

See Also

You can drag the Checkbox component checkbox component icon from the Palette's Basic category to the Visual Designer to create a single checkbox with an optional label.

If you want a set of checkboxes that is preformatted with labels in a group, you can use a Checkbox Group component instead.

You can drop a checkbox on a container component, like a table cell or group box.

A checkbox can represent any object, whether the object is of a predefined class like Boolean, Byte, Character, Double, Float, Integer, Long, Short, String, or of a class you define. A checkbox can also represent a primitive value.

 

A single checkbox can be used to represent several types of data:

A group of checkboxes can be used to represent:

The checkbox component can be useful in situations where the Checkbox Group component layout is not desirable, such as a checkbox used to select or deselect a table row.

If you right-click the component, you can choose one of the following pop-up menu items:

Detecting a Selected Checkbox

The checkbox component uses both the selected and selectedValue properties to pass information about the checkbox's selection status. The selected property is used to indicate that the checkbox is selected and a checkmark is displayed in the page. The selectedValue property is used to pass a data value for the checkbox. A checkbox is considered to be selected when the value of the selected property is equal to the value of the selectedValue property. You can display a checkbox as selected on the initial viewing of the page by assigning the same value to the selectedValue and the selected properties.

If the selectedValue property is not specified or its value is null, the checkbox behaves like a boolean control. In this case, if the checkbox is selected, the value of the selected property is a true Boolean instance. If the checkbox is not selected, the value of the selected property will be a false Boolean instance.

A value binding expression that evaluates to a primitive value can be assigned to the selected and selectedValue properties.

Using a Checkbox Component as a Boolean Control

If the selectedValue property is not specified or its value is null, the checkbox behaves like a boolean control.

To use the checkbox as a boolean control, do not specify a value for the selectedValue property. The checkbox is selected if the selected property is not null and has the value of a true Boolean instance or a boolean primitive value. If the checkbox is not selected, then the value of the selected property is a false Boolean instance or boolean primitive.

Using a Checkbox to Represent an Application-defined Value

The selectedValue property can be assigned an application-defined object value to represent the value of a selected checkbox. If the checkbox is selected, the value of the selected property is assigned the value of the selectedValue property.

If the value of the selectedValue property is an application-defined object, a converter must be registered to convert to and from a String value. The converter is used to encode the checkbox value as the value of the HTML <input> element and to decode the submitted value in a request. In addition the object must support an equals() method that returns true when the value of the selectedValue property is compared to the selected property value in order to detect a selected checkbox.

See Also
Checkbox Component Properties Window
Binding Component Properties
Working With Components
Component Tasks: Quick Reference
About the Visual Web Palette

Legal Notices