Listbox Component |
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 Outline 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 page, you can do a number of things with it:
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.
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. For a tutorial showing how to associate a listbox with an array, see the following web page: 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.
selected property so you can evaluate what the user chose after the page is submitted.
| Legal Notices. Copyright © 2006 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. |