Index.jsp Sample

This topic inludes the source code for the Index.jsp Sample.

Sample Location

This sample is located in the following directory in your WebLogic Workshop installation:

BEA_HOME/weblogic81/samples/workshop/SamplesApp/WebApp/navigation/selectTagNavigation/

Sample Source Code


001 <!--Generated by Weblogic Workshop-->
002 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
003 <%@ page language="java" contentType="text/html;charset=UTF-8"%>
004 <%@ taglib uri="netui-tags-databinding.tld" prefix="netui-data"%>
005 <%@ taglib uri="netui-tags-html.tld" prefix="netui"%>
006 <%@ page import="java.util.List,java.util.ArrayList,java.util.Iterator,databinding.DataBean" %>
007 
008 <%
009     if(request.getAttribute("dataBean"== null)
010     {
011         DataBean bean = new DataBean();
012         ArrayList selectOptions = new ArrayList();
013         selectOptions.add("Convertibles");
014         selectOptions.add("Specialty");
015         selectOptions.add("Vintage");
016         ArrayList selectDefaults = new ArrayList();
017         selectDefaults.add("Convertibles");
018         bean.setSelectOptions(selectOptions);
019         bean.setSelectionDefaults(selectDefaults);
020         request.setAttribute("dataBean", bean);
021     }
022 %>
023 
024 
025 <html>
026     <head>
027      <netui:base/>
028     <link href="../../resources/css/style.css" type="text/css" rel="stylesheet"/>
029         <title>
030             Select Cars Index Page
031         </title>
032     </head>
033     <body style="margin:0">
034         <jsp:include page="/resources/jsp/header.jsp"/> <br/> 
035         
036         <table width=100% align=left border=cellspacing=cellpadding=0>
037             <tr>
038                 <td width=5>
039                     &nbsp;
040                 </td>
041                 <td width=296 valign="top">
042         
043   <!-- Royalty-free images used in this sample are from Artville,
044        Digital Vision, EyeWire, PhotoDisc.  
045        http://creative.gettyimages.com -->
046         
047           <netui:image src="../../resources/images/tunnelCars.jpg" width="278" height="183" />
048 
049                 </td>
050                 <td valign="top">
051                     <p><b>Learn More About Hot Cars</b></p> 
052                  
053                  <p>&nbsp;</p>
054       
055                 <blockquote>
056                   <p>Select the car type, then click Go!</p>
057 
058                     <p>
059               <netui:form action="/selectedCar">
060             <netui:select size="1" optionsDataSource="{request.dataBean.selectOptions}"
061                       defaultValue="{request.dataBean.selectionDefaults}" dataSource="{actionForm.selection}" />
062                      &nbsp;&nbsp;
063           <netui:imageButton
064             rolloverImage="../../resources/images/go-button-rollover.gif"
065                      src="../../resources/images/go-button.gif" />
066             </netui:form>
067                     </p>
068           
069           <p>&nbsp;</p>
070           <hr width=200>
071           
072           <!-- In SelectCarsController.jpf, note how the "done" action
073                 uses return-action="begin". This action returns to the
074               calling page flow and runs its begin() method. -->    
075 
076               <p><netui:anchor action="done">Return to Navigation Samples Home</netui:anchor>
077                 
078                  </blockquote>
079 
080                 </td>
081             </tr>
082       
083   <tr>
084   <td width=5>&nbsp;</td>
085   <td width=296>&nbsp;</td>
086   <td class="white-text" bgcolor=navy>
087     &nbsp;Implementation Notes
088   </td>  
089   </tr>  
090   
091   <tr>
092   <td width=5>&nbsp;</td>
093   <td width=296>&nbsp;</td>
094   <td class="white-text" bgcolor="#8fc5ff">
095   <p>You can find the files that comprise this sample in:</p>
096     
097     <p>&lt;WEBLOGIC_HOME&gt;/samples/workshop/SampleApp/WebApp/SelectCars.</p>
098   
099     <p>The pull-down menu uses a &lt;netui:select&gt; JSP tag that
100   exists in a form. After you make a selection and click
101   the Go! imageButton, the form raises a <b>selectedCar</b> action.
102   SelectCarsController.jpf controller class
103   reads in the selected value from the form. 
104   In SelectCarsController.jpf, see the selectedCar method and the CarForm.
105   Based on the selected value, the controller class returns a forward
106   action that corresponds to the appropriate next JSP page.  
107   <p>In index.jsp, notice the following attributes used on the
108   &lt;netui:select&gt; tag: optionsDataSource, defaultValue, and dataSource.
109   In this case, we populated the first two attributes in index.jsp
110   by using an imported dataBean. 
111     
112     <p>There are other ways to bind data
113   to a read/write tag's attributes, and setting the values in the JSP is 
114     not the preferred way. Be sure to see the /dropdown/dropdownController.jpf
115     sample next!
116 
117   </td>
118   </tr>  
119       
120         </table>        
121     </body>
122 </html>