|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sas.Component | +--com.sas.servlet.beans.BaseTransformation | +--com.sas.servlet.beans.BaseListbox | +--com.sas.servlet.beans.html.Listbox
Transformation bean definition for creating an HTML SELECT element representing a Listbox. A listbox is a menu that allows either a single selection or multiple selections.
The Listbox Transformation Bean gathers the alternatives from a model via the setModelInterface method. A model must implement the com.sas.collection.StaticOrderedCollection interface in order to be used.
Problem: Create a document using JSP that contains a Listbox input field that allows multiple selections. The values of the Listbox elements differ from those that are shown to the user
Solution: Write a Java scriptlet in a JSP page that uses the Listbox Transformation Bean to create the HTML list box element.
JSP Page:
<html> <body> <p> This example shows a multiple selection list box generated by the Listbox Transformation Bean. </p> <FORM> <% // Create a new select object com.sas.servlet.beans.ListboxInterface listbox = new com.sas.servlet.beans.html.Listbox();
// Create the model com.sas.collection.StringCollection model = new com.sas.collection.StringCollection(); model.add("Red"); model.add("Green"); model.add("Orange"); model.add("Black"); model.add("White");
// Set the model listbox.setModelInterface(model);
// Set the name of the form object listbox.setName("color");
// Set the selected values. com.sas.collection.StringCollection selectedValues = new com.sas.collection.StringCollection(); selectedValues.add("Red"); selectedValues.add("Orange"); listbox.setSelectedItems(selectedValues);
// Allow multiple selections listbox.setMultipleSelections(true);
// Output the select listbox.write(out); %> </FORM> </body> </html>
HTML output:
<html> <body> <p> This example shows a multiple selection list box generated by the Listbox Transformation Bean. </p> <SELECT NAME="color" SIZE=4 MULTIPLE> <OPTION SELECTED VALUE="Red">Red <OPTION VALUE="Green">Green <OPTION SELECTED VALUE="Orange">Orange <OPTION VALUE="Black">Black <OPTION VALUE="White">White </SELECT> </body> </html>
Live element:
Constructor Summary | |
Listbox()
Construct a new Listbox |
|
Listbox(String name,
ModelInterface model)
Construct a new Listbox |
Method Summary | |
void |
write(PrintWriter out)
Writes the transformed representation of the object |
Methods inherited from class com.sas.servlet.beans.BaseListbox |
getDescriptionModel,
getMultipleSelections,
getRequiredInterfaces,
getSelectedIndex,
getSelectedIndexes,
getSelectedItem,
getSelectedItems,
getSize,
isSelected,
isSelected,
setDescriptionModel,
setMultipleSelections,
setSelectedIndex,
setSelectedIndexes,
setSelectedItem,
setSelectedItems,
setSize |
Methods inherited from class com.sas.servlet.beans.BaseTransformation |
getCustomAttributes,
getDescription,
getName,
getParent,
getRequest,
getResponse,
setCustomAttributes,
setDescription,
setName,
setParent,
setRequest,
setResponse,
toString,
write,
write,
write |
Methods inherited from class java.lang.Object |
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public Listbox()
public Listbox(String name, ModelInterface model)
name
- The field namemodel
- The model for the radio alternativesMethod Detail |
public void write(PrintWriter out) throws IOException
out
- The output stream
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |