RadioButtonsController.jpf Sample

This topic inludes the source code for the RadioButtonsController.jpf Sample.

Sample Location

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

BEA_HOME/weblogic81/samples/workshop/SamplesApp/WebApp/tagSamples/netui/radioButtons/

Sample Source Code


001 package tagSamples.netui.radioButtons;
002 import com.bea.wlw.netui.pageflow.FormData;
003 import com.bea.wlw.netui.pageflow.Forward;
004 import com.bea.wlw.netui.pageflow.PageFlowController;
005 import java.util.HashMap;
006 
007 /**
008  * @jpf:controller
009  * @jpf:view-properties view-properties::
010  <!-- This data is auto-generated. Hand-editing this section is not recommended. -->
011  <view-properties>
012  <pageflow-object id="pageflow:/tagSamples/netui/radioButtons/RadioButtonsController.jpf"/>
013  <pageflow-object id="action:processData.do#tagSamples.netui.radioButtons.RadioButtonsController.ProcessDataForm">
014  *   <property value="360" name="x"/>
015  *   <property value="100" name="y"/>
016  </pageflow-object>
017  <pageflow-object id="action:backToIndex.do">
018  *   <property value="480" name="x"/>
019  *   <property value="240" name="y"/>
020  </pageflow-object>
021  <pageflow-object id="action-call:@page:index.jsp@#@action:processData.do#tagSamples.netui.radioButtons.RadioButtonsController.ProcessDataForm@">
022  *   <property value="276,300,300,324" name="elbowsX"/>
023  *   <property value="92,92,92,92" name="elbowsY"/>
024  *   <property value="East_1" name="fromPort"/>
025  *   <property value="West_1" name="toPort"/>
026  </pageflow-object>
027  <pageflow-object id="page:index.jsp">
028  *   <property value="240" name="x"/>
029  *   <property value="100" name="y"/>
030  </pageflow-object>
031  <pageflow-object id="action-call:@page:showData.jsp@#@action:backToIndex.do@">
032  *   <property value="480,480,480,480" name="elbowsX"/>
033  *   <property value="144,170,170,196" name="elbowsY"/>
034  *   <property value="South_1" name="fromPort"/>
035  *   <property value="North_1" name="toPort"/>
036  </pageflow-object>
037  <pageflow-object id="page:showData.jsp">
038  *   <property value="480" name="x"/>
039  *   <property value="100" name="y"/>
040  </pageflow-object>
041  <pageflow-object id="forward:path#success#showData.jsp#@action:processData.do#tagSamples.netui.radioButtons.RadioButtonsController.ProcessDataForm@">
042  *   <property value="396,420,420,444" name="elbowsX"/>
043  *   <property value="92,92,92,92" name="elbowsY"/>
044  *   <property value="East_1" name="fromPort"/>
045  *   <property value="West_1" name="toPort"/>
046  *   <property value="success" name="label"/>
047  </pageflow-object>
048  <pageflow-object id="forward:path#success#index.jsp#@action:backToIndex.do@">
049  *   <property value="444,240,240,240" name="elbowsX"/>
050  *   <property value="232,232,188,144" name="elbowsY"/>
051  *   <property value="West_1" name="fromPort"/>
052  *   <property value="South_1" name="toPort"/>
053  *   <property value="success" name="label"/>
054  </pageflow-object>
055  <pageflow-object id="action:begin.do">
056  *   <property value="80" name="x"/>
057  *   <property value="100" name="y"/>
058  </pageflow-object>
059  <pageflow-object id="forward:path#success#index.jsp#@action:begin.do@">
060  *   <property value="116,160,160,204" name="elbowsX"/>
061  *   <property value="92,92,92,92" name="elbowsY"/>
062  *   <property value="East_1" name="fromPort"/>
063  *   <property value="West_1" name="toPort"/>
064  *   <property value="success" name="label"/>
065  </pageflow-object>
066  <pageflow-object id="formbean:tagSamples.netui.radioButtons.RadioButtonsController.ProcessDataForm"/>
067  <pageflow-object id="formbeanprop:tagSamples.netui.radioButtons.RadioButtonsController.ProcessDataForm#selection#java.lang.String"/>
068  </view-properties>
069  * ::
070  */
071 public class RadioButtonsController extends PageFlowController
072 {
073     public HashMap hashMap = new HashMap();
074     
075     /*
076      * This String holds the selected option when the user submits his/her choice.
077      */ 
078     public String selection = "";
079     
080     /*
081      * This String[] object is used to construct a set of radiobutton options.
082      * The radiobutton options generated from this String[] object have the same values 
083      * for their display texts and their underlying vaues.
084      */
085     public String[] strArr = {"value1""value2""value3"};
086     
087     public String defVal = "value3";
088     
089     protected void onCreate()
090     {
091         /*
092          * The following set of parameters are used to construct a 
093          * set of radiobutton options.
094          * By pointing a netui:radioButtonGroup at this HashMap,
095          * the appropriate radiobutton options are automatically generated.
096          * Also, because each entry in the HashMap contains two Strings,
097          * the options generated have different display texts and underlying values. 
098          */
099         hashMap.put("value1""Display Text 1");
100         hashMap.put("value2""Display Text 2");
101         hashMap.put("value3""Display Text 3");
102     }
103     
104     /**
105      * This method represents the point of entry into the pageflow
106      * @jpf:action
107      * @jpf:forward name="success" path="index.jsp"
108      */
109     protected Forward begin()
110     {
111         return new Forward("success");
112     }
113 
114     /**
115      * @jpf:action
116      * @jpf:forward name="success" path="showData.jsp"
117      */
118     protected Forward processData(ProcessDataForm form)
119     {
120         getRequest().setAttribute("submittedData", form);
121         return new Forward("success");
122     }
123 
124     /**
125      * @jpf:action
126      * @jpf:forward name="success" path="index.jsp"
127      */
128     protected Forward backToIndex()
129     {
130         return new Forward("success");
131     }
132 
133     /**
134      * FormData get and set methods may be overwritten by the Form Bean editor.
135      */
136     public static class ProcessDataForm extends FormData
137     {
138         private String selection;
139 
140         public void setSelection(String selection)
141         {
142             this.selection = selection;
143         }
144 
145         public String getSelection()
146         {
147             return this.selection;
148         }
149     }
150 }