The idea is to retrieve the data values from a database. In this case, I use a built in travel database from NetBeans.
There are two examples. The first one is a simple database binding, and the second uses the Option class to control the output.
The Option class allows us to insert any "filler" into the items we display in the list. Here is the code.
public Option[] getOptions() {
List<Option> options = new ArrayList<Option>();
personDataProvider.cursorFirst();
Option firstOption = new Option(personDataProvider.getValue("PERSON.PERSONID"), (String) personDataProvider.getValue("PERSON.NAME"));
options.add(firstOption);
Option filler = new Option(99999, "----------");
options.add(filler);
while (personDataProvider.cursorNext()) {
Option option = new Option(personDataProvider.getValue("PERSON.PERSONID"), (String) personDataProvider.getValue("PERSON.NAME"));
options.add(option);
}
return options.toArray(new Option[options.size()]);
}
Here is the source code DropDownListExample. The example was created using NetBeans 6.5.1 and Visual JSF plugin.
i eventually add more than 20 options to my dropdown and it works fine: they are displayed ... with a scrollbar.
ReplyDeleteDo you know how can I get rid of that scroll bar and just show all the options?
Thanks,
neidisch
The design of the component is to display options in a compact way. A determination was made to limit the number of items displayed, and provide a scrollable list if the limit was exceeded.
ReplyDeleteThis makes sense because otherwise you could have 250 items which extend past the page boundaries. I am sure you have seen such poorly designed components where the list goes off the screen.
If you really want to change it, you must check out the code, and modify the list limit to 20-25.