com.sas.servlet.beans.html
Class Choicebox

java.lang.Object
  |
  +--com.sas.Component
        |
        +--com.sas.servlet.beans.BaseTransformation
              |
              +--com.sas.servlet.beans.BaseChoicebox
                    |
                    +--com.sas.servlet.beans.html.Choicebox

public class Choicebox
extends BaseChoicebox

Transformation bean definition for creating an HTML SELECT element representing a Choicebox. The choicebox is a menu that allows a single selection selection from a drop-down list of items.

The Choicebox 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 choicebox input field.

Solution: Write a Java scriptlet in a JSP page that uses the Choicebox Transformation Bean to create the HTML choicebox element.

JSP Page:

 <html>
 <body>
 
 <p> This example shows a simple choicebox generated by the Choicebox Transformation Bean. </p>
 <FORM>
 <%
    // Create a new choicebox object
    com.sas.servlet.beans.ChoiceboxInterface choicebox =
        new com.sas.servlet.beans.html.Choicebox();

// Create the model com.sas.collection.StringCollection model = new com.sas.collection.StringCollection(); model.add("Red"); model.add("Green"); model.add("Orange"); // Set the model choicebox.setModelInterface(model);
// Set the selected index choicebox.setSelectedIndex(1);
// Output the select choicebox.write(out); %> </FORM> </body> </html>

HTML output:

 <html>
 <body>
 
 <p> This example shows a simple choicebox generated by the Choicebox Transformation Bean. </p>
 <SELECT NAME="Choicebox" SIZE=1>
 <OPTION VALUE="Red">Red
 <OPTION SELECTED VALUE="Green">Green
 <OPTION VALUE="Orange">Orange
 </SELECT>
 </body>
 </html>
 

Live element:



See Also:
Serialized Form

Constructor Summary
Choicebox()
          Construct a new Choicebox
Choicebox(String name, ModelInterface model)
          Construct a new Choicebox
 
Method Summary
 void write(PrintWriter out)
          Writes the transformed representation of the object
 
Methods inherited from class com.sas.servlet.beans.BaseChoicebox
getDescriptionModel, getRequiredInterfaces, getSelectedIndex, getSelectedItem, isSelected, isSelected, setDescriptionModel, setSelectedIndex, setSelectedItem
 
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

Choicebox

public Choicebox()
Construct a new Choicebox

Choicebox

public Choicebox(String name,
                 ModelInterface model)
Construct a new Choicebox
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