# FormController.jpf Sample

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

## Sample Source Code

`001 package tagSamples.netui.form; 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 006 /** 007 * @jpf:controller 008 * @jpf:view-properties view-properties:: 009 * <!-- This data is auto-generated. Hand-editing this section is not recommended. --> 010 * <view-properties> 011 * <pageflow-object id="pageflow:/tagSamples/netui/form/FormController.jpf"/> 012 * <pageflow-object id="formbean:tagSamples.netui.form.FormController.ProcessDataForm"/> 013 * <pageflow-object id="page:showData.jsp"> 014 * <property value="80" name="x"/> 015 * <property value="220" name="y"/> 016 * </pageflow-object> 017 * <pageflow-object id="formbeanprop:tagSamples.netui.form.FormController.ProcessDataForm#name#java.lang.String"/> 018 * <pageflow-object id="formbeanprop:tagSamples.netui.form.FormController.ProcessDataForm#age#int"/> 019 * <pageflow-object id="page:index.jsp"> 020 * <property value="240" name="x"/> 021 * <property value="100" name="y"/> 022 * </pageflow-object> 023 * <pageflow-object id="action-call:@page:index.jsp@#@action:processData.do#tagSamples.netui.form.FormController.ProcessDataForm@"> 024 * <property value="240,240,240,240" name="elbowsX"/> 025 * <property value="144,160,160,176" name="elbowsY"/> 026 * <property value="South_1" name="fromPort"/> 027 * <property value="North_1" name="toPort"/> 028 * </pageflow-object> 029 * <pageflow-object id="action:processData.do#tagSamples.netui.form.FormController.ProcessDataForm"> 030 * <property value="240" name="x"/> 031 * <property value="220" name="y"/> 032 * </pageflow-object> 033 * <pageflow-object id="forward:path#success#showData.jsp#@action:processData.do#tagSamples.netui.form.FormController.ProcessDataForm@"> 034 * <property value="204,160,160,116" name="elbowsX"/> 035 * <property value="212,212,212,212" name="elbowsY"/> 036 * <property value="West_1" name="fromPort"/> 037 * <property value="East_1" name="toPort"/> 038 * <property value="success" name="label"/> 039 * </pageflow-object> 040 * <pageflow-object id="action-call:@page:showData.jsp@#@action:begin.do@"> 041 * <property value="80,80,80,80" name="elbowsX"/> 042 * <property value="176,160,160,144" name="elbowsY"/> 043 * <property value="North_1" name="fromPort"/> 044 * <property value="South_1" name="toPort"/> 045 * </pageflow-object> 046 * <pageflow-object id="action:begin.do"> 047 * <property value="80" 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 * </view-properties> 058 * :: 059 */ 060 public class FormController extends PageFlowController 061 { 062 /* 063 * When the Controller file is first created, 064 * create a new instance of the Form Bean ProcessDataForm, 065 * set default values, 066 * and store the instance in the Session object. 067 * This instance is picked up by the index.jsp page 068 * and the default values are used to prepopulate the form fields there. 069 */ 070 protected void onCreate() 071 { 072 // Create a new Form Bean instance 073 ProcessDataForm formInstance = new ProcessDataForm(); 074 075 // Set default values. 076 formInstance.setAge(32); 077 formInstance.setName("John"); 078 079 // Store the instance in the Session object. 080 getSession().setAttribute("defaultValues", formInstance); 081 } 082 083 /** 084 * @jpf:action 085 * @jpf:forward name="success" path="index.jsp" 086 */ 087 protected Forward begin() 088 { 089 return new Forward("success"); 090 } 091 092 /** 093 * @jpf:action 094 * @jpf:forward name="success" path="showData.jsp" 095 */ 096 protected Forward processData(ProcessDataForm form) 097 { 098 getRequest().setAttribute("data", form); 099 return new Forward("success"); 100 } 101 102 public static class ProcessDataForm extends FormData 103 { 104 private int age; 105 106 private String name; 107 108 public void setName(String name) 109 { 110 this.name = name; 111 } 112 113 public String getName() 114 { 115 return this.name; 116 } 117 118 public void setAge(int age) 119 { 120 this.age = age; 121 } 122 123 public int getAge() 124 { 125 return this.age; 126 } 127 } 128 }`