Sample 32100: How to Use a JSP Radio Custom Tag with a Description Model
Overview
This sample demonstrates how to use the sas:Radio custom tag that is available with SAS® AppDevStudioTM. The sample also demonstrates how to utilize the description model, so that you can display a descriptive value to the user, while passing the unformatted value to the form.
Additional Documentation
- For a list of samples for common tasks, see SAS Note 32218.
- The SAS AppDev Studio Developer's Site contains detailed information that will assist you when developing Web applications with SAS AppDev Studio, including an API reference and the custom tag reference for the sas tagset.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
Instructions
- First, build a new web applicaton project in SAS AppDev Studio. It is not necessary to use a template for this example, but if you have a project based on a template, you may use it. If you are not familiar with building a web application project, instructions can be found in the following sample
- Create a new jsp page called radio.jsp under the WebContent directory in your web application. Replace the code in the jsp page with the code listed below
- Execute the jsp pae on the test Tomcat server. If you are not familiar with testing a web application, detailed instructions may be found in this sample
Code for radio.jsp
<%@ taglib uri="http://www.sas.com/taglib/sas" prefix="sas" %>
<%@ page pageEncoding="UTF-8"%>
<%@page import="javax.swing.DefaultComboBoxModel"%>
<html>
<head>
<link href="styles/sasComponents.css" rel="STYLESHEET" type="text/css">
</head>
<body>
<%
// This code will check to see if the form has been submitted.
// If so, the selected item will be stored so that the radio box will display it
// We will also print out the selected value, for demonstration purposes
String selectedItem = request.getParameter("radioBox1");
if( null != selectedItem ){
out.write( "<h3>You selected: " + request.getParameter( "radioBox1" ) + "</h3>");
}
//create a model and a description model
DefaultComboBoxModel model = new DefaultComboBoxModel();
DefaultComboBoxModel descriptionModel = new DefaultComboBoxModel();
for( int i=0;i<5;i++ ){
model.addElement("" + i);
descriptionModel.addElement( "Item " + i );
}
// Add the models to the page scope, so that the tag can use them
// The session scope could be used here also
pageContext.setAttribute("model", model);
pageContext.setAttribute("descriptionModel", descriptionModel);
%>
<sas:Form action="radio.jsp">
<sas:Radio id="radioBox1" name="radioBox1" selectedItem="<%=selectedItem%>" model="model" descriptionModel="descriptionModel"/>
<sas:PushButton text="submit"/>
</sas:Form>
</body>
</html>
|
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
The following results will be displayed after running the sample code and submitting the form.

This example demonstrates how to use a description model with a sas:Radio custom tag.
| Date Modified: | 2008-05-19 15:04:38 |
| Date Created: | 2008-05-13 16:55:07 |
Operating System and Release Information
| SAS System | SAS AppDev Studio | Microsoft® Windows® for x64 | 3.2 | | 9.1 TS1M3 SP4 | |
| Microsoft Windows 2000 Advanced Server | 3.2 | | 9.1 TS1M3 SP4 | |
| Microsoft Windows 2000 Datacenter Server | 3.2 | | 9.1 TS1M3 SP4 | |
| Microsoft Windows 2000 Server | 3.2 | | 9.1 TS1M3 SP4 | |
| Microsoft Windows 2000 Professional | 3.2 | | 9.1 TS1M3 SP4 | |
| Microsoft Windows NT Workstation | 3.2 | | 9.1 TS1M3 SP4 | |
| Microsoft Windows Server 2003 Datacenter Edition | 3.2 | | 9.1 TS1M3 SP4 | |
| Microsoft Windows Server 2003 Enterprise Edition | 3.2 | | 9.1 TS1M3 SP4 | |
| Microsoft Windows Server 2003 Standard Edition | 3.2 | | 9.1 TS1M3 SP4 | |
| Microsoft Windows XP Professional | 3.2 | | 9.1 TS1M3 SP4 | |
| Windows Vista | 3.2 | | 9.1 TS1M3 SP4 | |