|
||||||||||
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.BaseRadio | +--com.sas.servlet.beans.html.Radio
Transformation bean for creating an HTML Radio input field, which is used for attributes which can take a single value from a set of alternatives.
The Radio 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 radio button input field.
Solution: Write a Java scriptlet in a JSP page that uses the Radio Transformation Bean to create the HTML element.
JSP Page:
<html> <body> <p> This example shows a simple radio button generated by the Radio Transformation Bean. </p> <FORM> <% // Create a new radio object com.sas.servlet.beans.RadioInterface radio = new com.sas.servlet.beans.html.Radio();
// 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 radio.setModelInterface(model);
// Set the index of the selected item (0-based) radio.setSelectedIndex(1);
// Output the radio button radio.write(out); %> </FORM> </body> </html>
HTML output:
<html> <body> <p> This example shows a simple radio button generated by the Radio Transformation Bean. </p> <FORM> <INPUT TYPE=RADIO NAME="Radio Button" VALUE="Red">Red<br> <INPUT TYPE=RADIO NAME="Radio Button" VALUE="Green" CHECKED>Green<br> <INPUT TYPE=RADIO NAME="Radio Button" VALUE="Orange">Orange<br> </FORM> </body> </html>
Live element:
Problem: Create a document using JSP that contains a radio button input field. The values of the buttons differ from the description that is shown to the user.
Solution: Write a Java scriptlet in a JSP page that uses the Radio Transformation Bean with dual models to create the HTML element.
JSP Page:
<html> <body> <p> This example shows a simple radio button generated by the Radio Transformation Bean. </p> <FORM> <% // Create a new radio object com.sas.servlet.beans.RadioInterface radio = new com.sas.servlet.beans.html.Radio();
// Create the model com.sas.collection.StringCollection model = new com.sas.collection.StringCollection(); model.add("R"); model.add("G"); model.add("O");
// Set the model radio.setModelInterface(model);
// Create the model for the descriptions com.sas.collection.StringCollection descModel = new com.sas.collection.StringCollection(); descModel.add("Red"); descModel.add("Green"); descModel.add("Orange"); // Set the model for the descriptions radio.setDescriptionModel(descModel);
// Set the name of the radio button radio.setName("Radio2");
// Set the value of the selected item radio.setSelectedItem("G");
// Output the radio button radio.write(out); %> </FORM> </body> </html>
HTML output:
<html> <body> <p> This example shows a simple radio button generated by the Radio Transformation Bean. </p> <FORM> <INPUT TYPE=RADIO NAME="Radio2" VALUE="R">Red<br> <INPUT TYPE=RADIO NAME="Radio2" VALUE="G" CHECKED>Green<br> <INPUT TYPE=RADIO NAME="Radio2" VALUE="O">Orange<br> </FORM> </body> </html>
Live element:
Constructor Summary | |
Radio()
Construct a new Radio input field |
|
Radio(String name,
ModelInterface model)
Construct a new Radio input field |
Method Summary | |
void |
write(PrintWriter out)
Writes the transformed representation of the object |
Methods inherited from class com.sas.servlet.beans.BaseRadio |
getDescriptionModel,
getRequiredInterfaces,
getSelectedIndex,
getSelectedItem,
isBreak,
isSelected,
isSelected,
setBreak,
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 Radio()
public Radio(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 |