You can drag the Checkbox Group component from the Palette's Basic category to the Visual Designer to create a table of labeled checkboxes.
The checkboxes are rendered in rows and columns in an HTML <table>
element. The number of rows is defined by the number of checkboxes. The number of columns is defined by the columns
property. The default layout is a single vertical column. If you want the checkboxes laid out in a single row, you can set the columns
property to the number of checkboxes.
The items
property is bound to an array, a list, or a collection of com.sun.webui.jsf.model.Option
objects that populate the list. Right-click the component and choose Bind to Data to set this property. In the you can see the default object that populates the list, which has a name similar to checkboxGroup1DefaultOptions
. The option labels become the checkbox labels. When the user selects
one or more checkboxes, the component's selected
property contains an array of the selected values.
You set the selected
property to associate the component with a model object that picks up the items selected by the user. The model object must be an array of objects whose values represent the values of the com.sun.webui.jsf.model.Option
objects in the list. The first time the component is rendered, the options that correspond to the value of the selected
property, if there are any, are marked as selected.
For information on binding the component to an object to set up the list, see Bind to Data below.
After dragging the component to the Visual Designer, you can do a number of things with it:
validate
method so you can insert code to validate the value of the component.processValueChange
method so you can insert code that executes when the value of this component changes (for example, the user changes the value of another component that is controlling the value of this component).common_timeoutSubmitForm(this.form, 'component-id');
. At runtime, this code causes the form to be automatically submitted if the user changes the component value. Once the form is submitted, conversion and validation occur on the server and any value change listener methods execute, and then the page is redisplayed.
A component configured to Auto-Submit on Change can use virtual forms to limit the input fields that are processed when the form is submitted. If the auto-submit component is defined to submit a virtual form, only the participants in that virtual form will be processed when the auto-submit occurs.
items
property to an object or to a data provider, as described in Bind to Data Dialog Box.
items
property to an object, select the Bind to Object tab and then select a bean property that will be used to populate the list. The bean property must be an Object
array, map, or collection whose members are all subclasses of com.sun.webui.jsf.model.Option
.
items
property to a data provider for a database table or JavaBeans object that will be used to populate the list, select the Bind to Data Provider tab and choose a data provider.selected
property, which you can bind to an Object
array, or an array of primitives. You must have added the array to a managed bean, such as the session bean, as a property. You can use this bean property to evaluate what the user chose after the page is submitted.checkboxgroup#defaultOptions
object and change the displayed checkboxes. It is more likely that you will want to bind the items
property to a database or object to use to set checkbox list items, as described above under Bind to Data. id
attribute. In the page bean, this property's value is the name of the CheckboxGroup
object.for
property is set to the first checkbox in the group.label
property. Values are 1 (strong), 2 (medium), and 3 (weak). The default value is 2.