|
||||||||||
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.BaseChoicebox | +--com.sas.servlet.beans.html.Choicebox
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:
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 java.lang.Object |
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public Choicebox()
public Choicebox(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 |