com.sas.servlet.beans.html
Class Listbox

java.lang.Object
  |
  +--com.sas.Component
        |
        +--com.sas.servlet.beans.BaseTransformation
              |
              +--com.sas.servlet.beans.BaseListbox
                    |
                    +--com.sas.servlet.beans.html.Listbox

public class Listbox
extends BaseListbox

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:

See Also:
Serialized Form

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 com.sas.Component
addLink, addPropertyChangeListener, addVetoableChangeListener, anyPropertyChangeListeners, attachModel, attachView, beansIsDesignTime, beansSetDesignTime, clone, clone, detachModel, detachView, dumpComponent, firePropertyChange, firePropertyChange, fireVetoableChange, getComponentDescription, getComponentSupportInfo, getEventMethod, getEventValues, getExtendedBeanInfo, getLinkInfo, getModelInterface, getResources, getStringResource, getViewInterfaceSupportInfo, initialize, initializeComponent, isDesignTime, isLinked, propertyChange, queryLinks, queryLinks, refresh, removeAllLinks, removeInterfaceTraps, removeLink, removePropertyChangeListener, removeVetoableChangeListener, setComponentDescription, setComponentSupportInfo, setDefaultValues, setLinkInfo, setModelInterface, setRequiredInterfaces, setViewInterfaceSupportInfo, supportsListenerInterface, supportsRequiredInterfaces, trapInterfaceEvents, validateObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Listbox

public Listbox()
Construct a new Listbox

Listbox

public Listbox(String name,
               ModelInterface model)
Construct a new Listbox
Parameters:
name - The field name
model - The model for the radio alternatives
Method Detail

write

public void write(PrintWriter out)
           throws IOException
Writes the transformed representation of the object
Parameters:
out - The output stream
Overrides:
write in class BaseTransformation


Version: 1.2.20000317.001 Formatted: 2000/07/06 15:57:33PM