listbox component, multiple selections and databases
Hello, I have a listbox component bound to a database. It populates alright, but when I want to set the default selections and add an array of String objects to the listbox's selected property, they never appear selected. I set the array in the prerender method. Has anyone done this before? I searched and only found different situations.
TIA,
Scott
[370 byte] By [
SLM] at [2007-11-26 9:17:26]

# 1
This is another documentation oversight.If you bind a listbox component to a database, be sure to check what kind of object is being used for the listbox values. Then, for the selected property, use an array of objects OF THAT TYPE. An array of String's will NOT work.....
SLM at 2007-7-6 23:45:13 >

# 2
Here is an excerpt from http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/abo ut_components.html
"One way to preselect items is to call setSelectedValue(Object[]) or setSelectedValue(Object) from the prerender() method. You pass in the return values of the items that you want preselected. ..."
"For the items property, you specify a display label and a return value for each item in the list. The selected property returns an object, or, if the multiple property is selected, an array of objects, of the same type as the return values. "
" If the multiple property is false, the value of the component's selected property matches the return value of the selected list item. If the multiple property is set to true (to enable the user to select more than one item), you must bind selected to an array of Object, an array of primitives, or java.util.List. If you use java.util.List, you must specify a converter for the type of the List members unless they are String objects. The array contains values that match the return values of the selected items."