com.sas.servlet.beans.html
Class Radio

java.lang.Object
  |
  +--com.sas.Component
        |
        +--com.sas.servlet.beans.BaseTransformation
              |
              +--com.sas.servlet.beans.BaseRadio
                    |
                    +--com.sas.servlet.beans.html.Radio

public class Radio
extends BaseRadio

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:

Red
Green
Orange


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:

Red
Green
Orange

See Also:
Serialized Form

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 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

Radio

public Radio()
Construct a new Radio input field

Radio

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