The dynamic list box support allows the SELECT element to change its options dynamically
by using the values given by the server.
To use this, HTML needs to declare the SELECT element:
The SELECT element may have initial option values (in fact in most cases having initial
values are desirable to avoid the client from submitting the form before the AJAX call
updates the SELECT element.) It should also have an ID (although if you can get
to the DOM element by other means, that's fine, too.)
Other parts of the HTML can initiate the SELECT element update by using the "updateListBox"
function, defined in hudson-behavior.js. The following example does it
when the value of the textbox changes:
The first argument is the SELECT element or the ID of it (see Prototype.js $(...) function.)
The second argument is the URL that returns the options list.
The URL usually maps to the doXXX method on the server, which uses ListBoxModel
for producing option values. See the following example:
public ListBoxModel doOptionValues(@QueryParameter("value") String value) throws IOException, ServletException {
ListBoxModel m = new ListBoxModel();
for(int i=0; i<5; i++)
m.add(value+i,value+i);
// make the third option selected initially
m.get(3).selected = true;
return m;
}