com.sas.servlet.beans.wml
Class Listbox

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

public class Listbox
extends BaseListbox

Transformation bean for creating a WML Listbox field, which is used for attributes which can take multiple values from a set of alternatives.

The Listbox Transformation Bean gathers the alternatives from various models 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 field.

Solution: Write a Java scriptlet in a JSP page that uses the Listbox Transformation Bean to create the WML element.

JSP Page:

 
 <?xml version="1.0"?>
 <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
 <wml>
 <card>
 <p>
 
 <%
    response.setContentType("text/vnd.wap.wml");
 
    // Create a new Listbox object
    com.sas.servlet.beans.ListboxInterface listbox =
        new com.sas.servlet.beans.wml.Listbox();

// 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 listbox.setModelInterface(model);
// Set the index of the selected item (0-based) listbox.setSelectedIndex(1);
// Output the listbox button listbox.write(out); %> </p> </card> </wml>

Browser WML Listbox:

listbox1.jpg

BaseListbox

See Also:
Serialized Form

Constructor Summary
Listbox()
          Construct a new listbox input field
Listbox(String name, ModelInterface model)
          Construct a new listbox input field with a default name and model
 
Method Summary
 String getIndexName()
          Gets the name of the WML variable that is used to store the selectedIndex.
 boolean getMultipleSelections()
          Gets the multiple selection attribute.
 StaticOrderedCollectionInterface getOnPickModel()
          Gets the model to be used for the destinations of the listbox options.
 int getSize()
          Gets the size attribute.
 String getTitle()
          Gets the title to be displayed for this bean.
 void setIndexName(String value)
          Sets the name of the WML variable that is used to store the selectedIndex.
 void setMultipleSelections(boolean value)
          Sets the multiple selection attribute allowing multiple selections of values in the list.
 void setOnPickModel(StaticOrderedCollectionInterface model)
          Sets the model to be used for the destinations of the listbox options.
 void setSize(int value)
          Sets the size attribute.
 void setTitle(String value)
          Sets the title to be displayed for this bean.
 void write(PrintWriter out)
          Writes the transformed representation of the object
 
Methods inherited from class com.sas.servlet.beans.BaseListbox
getDescriptionModel, getRequiredInterfaces, getSelectedIndex, getSelectedIndexes, getSelectedItem, getSelectedItems, isSelected, isSelected, setDescriptionModel, setSelectedIndex, setSelectedIndexes, setSelectedItem, setSelectedItems
 
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 input field

Listbox

public Listbox(String name,
               ModelInterface model)
Construct a new listbox input field with a default name and model
Parameters:
name - The field name
model - The model for the listbox alternatives
Method Detail

setOnPickModel

public void setOnPickModel(StaticOrderedCollectionInterface model)
Sets the model to be used for the destinations of the listbox options. The browser will navigate to these destinations when an item is selected. There is a one to one relationship between the onPickModel and the listbox's contents.
Parameters:
model - The collection to use for the destinations

getOnPickModel

public StaticOrderedCollectionInterface getOnPickModel()
Gets the model to be used for the destinations of the listbox options. The browser will navigate to these destinations when an item is selected. There is a one to one relationship between the onPickModel and the listbox's contents.
Returns:
The collection to use for the destinations

setTitle

public void setTitle(String value)
Sets the title to be displayed for this bean.
Parameters:
title - The string to be displayed as the title

getTitle

public String getTitle()
Gets the title to be displayed for this bean.

setIndexName

public void setIndexName(String value)
Sets the name of the WML variable that is used to store the selectedIndex.
Parameters:
indexName - The name of the WML variable used to store the selectedIndex

getIndexName

public String getIndexName()
Gets the name of the WML variable that is used to store the selectedIndex.
Returns:
The name of the WML variable used to store the selectedIndex

setSize

public void setSize(int value)
Sets the size attribute. Not supported.
Parameters:
size - The maximum number of values visible to the user
Overrides:
setSize in class BaseListbox

getSize

public int getSize()
Gets the size attribute. Not supported.
Returns:
The maximum number of values visible to the user
Overrides:
getSize in class BaseListbox

setMultipleSelections

public void setMultipleSelections(boolean value)
Sets the multiple selection attribute allowing multiple selections of values in the list. Not supported, value is always true.
Parameters:
multiple - true if multiple selections are allowed
Overrides:
setMultipleSelections in class BaseListbox

getMultipleSelections

public boolean getMultipleSelections()
Gets the multiple selection attribute. Not supported, value is always true.
Returns:
true if multiple selections are allowed
Overrides:
getMultipleSelections in class BaseListbox

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