# SelectController.jpf Sample

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

## Sample Source Code

`001 package tagSamples.netui.select; 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 import java.util.HashMap; 007 008 /** 009 * This page flow shows how to handle submissions from a <netui:select> tag 010 * which includes the attribute multiple="true". 011 * 012 * When the tag <netui:select multiple="true"> submits, the FormBean should contain 013 * a String[] to hold the multi-selected options. 014 * 015 * @jpf:controller 016 * @jpf:view-properties view-properties:: 017 * <!-- This data is auto-generated. Hand-editing this section is not recommended. --> 018 * <view-properties> 019 * <pageflow-object id="pageflow:/tagSamples/netui/select/selectController.jpf"/> 020 * <pageflow-object id="action:begin.do"> 021 * <property value="200" name="x"/> 022 * <property value="100" name="y"/> 023 * </pageflow-object> 024 * <pageflow-object id="action:submit.do#tagSamples.netui.select.selectController.SubmitForm"> 025 * <property value="340" name="x"/> 026 * <property value="240" name="y"/> 027 * </pageflow-object> 028 * <pageflow-object id="action:backToWebAppSamples.do"> 029 * <property value="80" name="x"/> 030 * <property value="240" name="y"/> 031 * </pageflow-object> 032 * <pageflow-object id="action-call:@page:index.jsp@#@action:submit.do#tagSamples.netui.select.selectController.SubmitForm@"> 033 * <property value="340,340,340,340" name="elbowsX"/> 034 * <property value="144,170,170,196" name="elbowsY"/> 035 * <property value="South_1" name="fromPort"/> 036 * <property value="North_1" name="toPort"/> 037 * </pageflow-object> 038 * <pageflow-object id="page:index.jsp"> 039 * <property value="340" name="x"/> 040 * <property value="100" name="y"/> 041 * </pageflow-object> 042 * <pageflow-object id="action-call:@page:show.jsp@#@action:begin.do@"> 043 * <property value="200,200,200,200" name="elbowsX"/> 044 * <property value="196,170,170,144" name="elbowsY"/> 045 * <property value="North_1" name="fromPort"/> 046 * <property value="South_1" name="toPort"/> 047 * </pageflow-object> 048 * <pageflow-object id="page:show.jsp"> 049 * <property value="200" name="x"/> 050 * <property value="240" name="y"/> 051 * </pageflow-object> 052 * <pageflow-object id="external-jpf:/Controller.jpf"> 053 * <property value="80" name="x"/> 054 * <property value="400" name="y"/> 055 * </pageflow-object> 056 * <pageflow-object id="forward:path#success#index.jsp#@action:begin.do@"> 057 * <property value="236,270,270,304" name="elbowsX"/> 058 * <property value="92,92,92,92" name="elbowsY"/> 059 * <property value="East_1" name="fromPort"/> 060 * <property value="West_1" name="toPort"/> 061 * <property value="success" name="label"/> 062 * </pageflow-object> 063 * <pageflow-object id="forward:path#success#show.jsp#@action:submit.do#tagSamples.netui.select.selectController.SubmitForm@"> 064 * <property value="304,270,270,236" name="elbowsX"/> 065 * <property value="232,232,232,232" name="elbowsY"/> 066 * <property value="West_1" name="fromPort"/> 067 * <property value="East_1" name="toPort"/> 068 * <property value="success" name="label"/> 069 * </pageflow-object> 070 * <pageflow-object id="forward:path#success#/Controller.jpf#@action:backToWebAppSamples.do@"> 071 * <property value="80,80,80,80" name="elbowsX"/> 072 * <property value="284,320,320,356" name="elbowsY"/> 073 * <property value="South_1" name="fromPort"/> 074 * <property value="North_1" name="toPort"/> 075 * <property value="success" name="label"/> 076 * </pageflow-object> 077 * <pageflow-object id="formbeanprop:tagSamples.netui.select.selectController.SubmitForm#selections#java.lang.String[]"/> 078 * <pageflow-object id="formbean:tagSamples.netui.select.selectController.SubmitForm"/> 079 * </view-properties> 080 * :: 081 */ 082 public class selectController extends PageFlowController 083 { 084 // When you point the optionsDataSource attribute at the following String[] 085 // a set of HTML option tags is automatically generated. 086 public String[] _options = {"red", "green", "blue", "orange", "pink", "aqua", "black", "brown", "tan"}; 087 088 public HashMap _hashMap = new HashMap(); 089 090 protected void onCreate() 091 { 092 _hashMap.put("#ff3333", "red"); 093 _hashMap.put("#3333ff", "blue"); 094 _hashMap.put("#33ff33", "green"); 095 } 096 097 public String[] _preSelectedOptions = {"green", "blue"}; 098 099 /** 100 * @jpf:action 101 * @jpf:forward name="success" path="index.jsp" 102 */ 103 protected Forward begin() 104 { 105 /* 106 * Passing the name/value pair "_preSelectedOptions"/_preSelectedOptions 107 * to the JSP page makes the name/value pair available as a page input 108 * on the JSP page. On the JSP page, the name/value can be accessed 109 * by the data binding expression {pageInput._preSelectedOptions}. 110 */ 111 return new Forward("success", "_preSelectedOptions", _preSelectedOptions); 112 } 113 114 /** 115 * @jpf:action 116 * @jpf:forward name="success" path="show.jsp" 117 */ 118 protected Forward submit(SubmitForm form) 119 { 120 getRequest().setAttribute("submittedData", form.selections); 121 return new Forward("success"); 122 } 123 124 /** 125 * @jpf:action 126 * @jpf:forward name="success" path="/Controller.jpf" 127 */ 128 protected Forward backToWebAppSamples() 129 { 130 return new Forward("success"); 131 } 132 133 /* 134 * The <netui:select> tags are databound to this 135 * FormBean. 136 * The String[] selections holds the (potentially) multiple selections submitted from the <netui:select> tags. 137 */ 138 public static class SubmitForm extends FormData 139 { 140 private String[] selections; 141 142 public void setSelections(String[] selections) 143 { 144 this.selections = selections; 145 } 146 147 public String[] getSelections() 148 { 149 return this.selections; 150 } 151 } 152 }`