# Controller.jpf Sample

This topic inludes the source code for the Controller.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/checkBoxGroup/

## Sample Source Code

`001 package tagSamples.netui.checkBoxGroup; 002 003 import com.bea.wlw.netui.pageflow.FormData; 004 import com.bea.wlw.netui.pageflow.Forward; 005 import com.bea.wlw.netui.pageflow.PageFlowController; 006 007 /** 008 * This page flow shows how to handle submissions from a <netui:checkBoxGroup>. 009 * 010 * Note that the Form Bean SubmitForm contains a String[] to hold the 011 * multiple selections submitted from the <netui:checkBoxGroup>. 012 * 013 * @jpf:controller 014 * @jpf:view-properties view-properties:: 015 * <!-- This data is auto-generated. Hand-editing this section is not recommended. --> 016 * <view-properties> 017 * <pageflow-object id="pageflow:/tagSamples/netui/checkBoxGroup/Controller.jpf"/> 018 * <pageflow-object id="action:begin.do"> 019 * <property value="80" name="x"/> 020 * <property value="100" name="y"/> 021 * </pageflow-object> 022 * <pageflow-object id="action:submit.do#tagSamples.netui.checkBoxGroup.Controller.SubmitForm"> 023 * <property value="360" name="x"/> 024 * <property value="100" name="y"/> 025 * </pageflow-object> 026 * <pageflow-object id="action:backToIndex.do"> 027 * <property value="500" name="x"/> 028 * <property value="220" name="y"/> 029 * </pageflow-object> 030 * <pageflow-object id="action-call:@page:index.jsp@#@action:submit.do#tagSamples.netui.checkBoxGroup.Controller.SubmitForm@"> 031 * <property value="276,300,300,324" name="elbowsX"/> 032 * <property value="92,92,92,92" name="elbowsY"/> 033 * <property value="East_1" name="fromPort"/> 034 * <property value="West_1" name="toPort"/> 035 * </pageflow-object> 036 * <pageflow-object id="page:index.jsp"> 037 * <property value="240" name="x"/> 038 * <property value="100" name="y"/> 039 * </pageflow-object> 040 * <pageflow-object id="action-call:@page:show.jsp@#@action:backToIndex.do@"> 041 * <property value="500,500,500,500" name="elbowsX"/> 042 * <property value="144,160,160,176" name="elbowsY"/> 043 * <property value="South_1" name="fromPort"/> 044 * <property value="North_1" name="toPort"/> 045 * </pageflow-object> 046 * <pageflow-object id="page:show.jsp"> 047 * <property value="500" name="x"/> 048 * <property value="100" name="y"/> 049 * </pageflow-object> 050 * <pageflow-object id="forward:path#success#index.jsp#@action:begin.do@"> 051 * <property value="116,160,160,204" name="elbowsX"/> 052 * <property value="92,92,92,92" name="elbowsY"/> 053 * <property value="East_1" name="fromPort"/> 054 * <property value="West_1" name="toPort"/> 055 * <property value="success" name="label"/> 056 * </pageflow-object> 057 * <pageflow-object id="forward:path#success#show.jsp#@action:submit.do#tagSamples.netui.checkBoxGroup.Controller.SubmitForm@"> 058 * <property value="396,430,430,464" name="elbowsX"/> 059 * <property value="92,92,92,92" name="elbowsY"/> 060 * <property value="East_1" name="fromPort"/> 061 * <property value="West_1" name="toPort"/> 062 * <property value="success" name="label"/> 063 * </pageflow-object> 064 * <pageflow-object id="forward:path#success#index.jsp#@action:backToIndex.do@"> 065 * <property value="464,320,320,276" name="elbowsX"/> 066 * <property value="212,212,103,103" name="elbowsY"/> 067 * <property value="West_1" name="fromPort"/> 068 * <property value="East_2" name="toPort"/> 069 * <property value="success" name="label"/> 070 * </pageflow-object> 071 * <pageflow-object id="formbeanprop:tagSamples.netui.checkBoxGroup.Controller.SubmitForm#states#java.lang.String[]"/> 072 * <pageflow-object id="formbeanprop:tagSamples.netui.checkBoxGroup.Controller.SubmitForm#defaultState#java.lang.String[]"/> 073 * <pageflow-object id="formbean:tagSamples.netui.checkBoxGroup.Controller.SubmitForm"/> 074 * </view-properties> 075 * :: 076 */ 077 public class Controller 078 extends PageFlowController 079 { 080 private String[] availableStates = null; 081 082 public String[] availableOptions = {"option1", "option2", "option3"}; 083 084 /** 085 * @jpf:action 086 * @jpf:forward name="success" path="index.jsp" 087 */ 088 protected Forward begin() 089 { 090 return new Forward("success"); 091 } 092 093 /** 094 * @jpf:action 095 * @jpf:forward name="success" path="show.jsp" 096 */ 097 protected Forward submit(SubmitForm form) 098 { 099 getRequest().setAttribute("selections", form.states); 100 return new Forward("success", form); 101 } 102 103 /** 104 * Populate the list of states 105 */ 106 protected void onCreate() 107 { 108 availableStates = new String[] {"ME", "MA", "NH", "VT", "RI", "CT"}; 109 } 110 111 /** 112 * JavaBean getter for accessing the list of states. 113 */ 114 public String[] getAvailableStates() {return availableStates;} 115 116 /** 117 * @jpf:action 118 * @jpf:forward name="success" path="index.jsp" 119 */ 120 protected Forward backToIndex() 121 { 122 return new Forward("success"); 123 } 124 125 public static class SubmitForm extends FormData 126 { 127 private String[] defaultState = {"MA", "ME"}; 128 private String[] states; 129 130 public void setStates(String[] states) 131 { 132 this.states = states; 133 } 134 135 public String[] getStates() 136 { 137 return this.states; 138 } 139 140 public void setDefaultState(String[] defaultState) 141 { 142 this.defaultState = defaultState; 143 } 144 145 public String[] getDefaultState() 146 { 147 return this.defaultState; 148 } 149 } 150 }`