|
||||||||||
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.wml.Listbox
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:
BaseListbox
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 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 listbox alternativesMethod Detail |
public void setOnPickModel(StaticOrderedCollectionInterface model)
model
- The collection to use for the destinationspublic StaticOrderedCollectionInterface getOnPickModel()
public void setTitle(String value)
title
- The string to be displayed as the titlepublic String getTitle()
public void setIndexName(String value)
indexName
- The name of the WML variable used to store the selectedIndexpublic String getIndexName()
public void setSize(int value)
size
- The maximum number of values visible to the userpublic int getSize()
public void setMultipleSelections(boolean value)
multiple
- true if multiple selections are allowedpublic boolean getMultipleSelections()
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 |