You can drag the Listbox component from
the Palette's Basic category to the Visual Designer to create a component that
enables the user to select items from a list of items. If
the box is too small to contain the items in the list, the list
box includes scrollbars.
By default, only one item can be selected in the list. The multiple
property determines whether one item or multiple items can be selected by the user.
You can set the items
property to associate the component either with a database table or with an array, a collection, or a map of com.sun.rave.web.ui.model.Option
objects to populate the list. Right-click the component and choose Bind to Data to set this property. In the Navigator window, you can see the default object that populates the list, which has a name similar to listbox1DefaultOptions
.
You set the selected
property to associate the component with a model object that picks up the list items selected by the user. The model object must be an array of objects whose values represent the values of the com.sun.rave.web.ui.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.
After adding a Listbox Component to a Visual Web JSF page, you can do a number of things with it:
id
attribute. In the page bean, this property's value is
the name of the Listbox
object. rows
property to 1, the listbox renders as a drop down list on most browsers.labelOnTop
property or next to the list if you do not select the labelOnTop
property.
label
property is not as flexible as the Label component. You can use the Label component if you want more control over the label's appearance, such as positioning of the label relative to the component.required
icon. 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)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.rave.web.ui.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.onclick
property to 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.
selected
property so you can evaluate what the user chose after the page is submitted.