# 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/struts/validation/validator/

## Sample Source Code

`001 package struts.validation.validator; 002 003 import com.bea.wlw.netui.pageflow.*; 004 import org.apache.struts.action.*; 005 import javax.servlet.http.*; 006 007 008 /** 009 * @jpf:controller nested="true" struts-merge="/WEB-INF/strutsValidator-merge-config.xml" 010 * @jpf:message-resources resources="validation.validator.Messages" 011 * @jpf:view-properties view-properties:: 012 * <!-- This data is auto-generated. Hand-editing this section is not recommended. --> 013 * <view-properties> 014 * <pageflow-object id="pageflow:/validation/validator/Controller.jpf"/> 015 * <pageflow-object id="action:begin.do"> 016 * <property value="40" name="x"/> 017 * <property value="60" name="y"/> 018 * </pageflow-object> 019 * <pageflow-object id="action:submitForm.do#validation.validator.Controller.MyForm"> 020 * <property value="260" name="x"/> 021 * <property value="200" name="y"/> 022 * </pageflow-object> 023 * <pageflow-object id="action:exit.do"> 024 * <property value="420" name="x"/> 025 * <property value="60" name="y"/> 026 * </pageflow-object> 027 * <pageflow-object id="action-call:@page:formPage.jsp@#@action:submitForm.do#validation.validator.Controller.MyForm@"> 028 * <property value="260,260,260,260" name="elbowsX"/> 029 * <property value="104,130,130,156" name="elbowsY"/> 030 * <property value="South_1" name="fromPort"/> 031 * <property value="North_1" name="toPort"/> 032 * </pageflow-object> 033 * <pageflow-object id="action-call:@page:formPage.jsp@#@action:exit.do@"> 034 * <property value="296,340,340,384" name="elbowsX"/> 035 * <property value="52,52,52,52" name="elbowsY"/> 036 * <property value="East_1" name="fromPort"/> 037 * <property value="West_1" name="toPort"/> 038 * </pageflow-object> 039 * <pageflow-object id="page:formPage.jsp"> 040 * <property value="260" name="x"/> 041 * <property value="60" name="y"/> 042 * </pageflow-object> 043 * <pageflow-object id="action-call:@page:success.jsp@#@action:begin.do@"> 044 * <property value="40,40,40,40" name="elbowsX"/> 045 * <property value="156,130,130,104" name="elbowsY"/> 046 * <property value="North_1" name="fromPort"/> 047 * <property value="South_1" name="toPort"/> 048 * </pageflow-object> 049 * <pageflow-object id="page:success.jsp"> 050 * <property value="40" name="x"/> 051 * <property value="200" name="y"/> 052 * </pageflow-object> 053 * <pageflow-object id="forward:path#formPage#formPage.jsp#@action:begin.do@"> 054 * <property value="76,150,150,224" name="elbowsX"/> 055 * <property value="52,52,52,52" name="elbowsY"/> 056 * <property value="East_1" name="fromPort"/> 057 * <property value="West_1" name="toPort"/> 058 * <property value="formPage" name="label"/> 059 * </pageflow-object> 060 * <pageflow-object id="forward:path#success#success.jsp#@action:submitForm.do#validation.validator.Controller.MyForm@"> 061 * <property value="224,150,150,76" name="elbowsX"/> 062 * <property value="192,192,192,192" name="elbowsY"/> 063 * <property value="West_1" name="fromPort"/> 064 * <property value="East_1" name="toPort"/> 065 * <property value="success" name="label"/> 066 * </pageflow-object> 067 * <pageflow-object id="forward:return-to#failure#currentPage#@action:submitForm.do#validation.validator.Controller.MyForm@"> 068 * <property value="260,260,260,260" name="elbowsX"/> 069 * <property value="244,270,270,296" name="elbowsY"/> 070 * <property value="South_1" name="fromPort"/> 071 * <property value="North_1" name="toPort"/> 072 * <property value="failure" name="label"/> 073 * </pageflow-object> 074 * <pageflow-object id="exit:begin"> 075 * <property value="420" name="x"/> 076 * <property value="200" name="y"/> 077 * </pageflow-object> 078 * <pageflow-object id="forward:return-action#previousPageFlowBegin#begin#@action:exit.do@"> 079 * <property value="420,420,420,420" name="elbowsX"/> 080 * <property value="104,130,130,156" name="elbowsY"/> 081 * <property value="South_1" name="fromPort"/> 082 * <property value="North_1" name="toPort"/> 083 * <property value="previousPageFlowBegin" name="label"/> 084 * </pageflow-object> 085 * <pageflow-object id="formbeanprop:validation.validator.Controller.MyForm#email#java.lang.String"/> 086 * <pageflow-object id="formbeanprop:validation.validator.Controller.MyForm#age#java.lang.String"/> 087 * <pageflow-object id="formbean:validation.validator.Controller.MyForm"/> 088 * <pageflow-object id="return-to:@forward:return-to#failure#currentPage#@action:submitForm.do#validation.validator.Controller.MyForm@@"> 089 * <property value="260" name="x"/> 090 * <property value="340" name="y"/> 091 * </pageflow-object> 092 * </view-properties> 093 * :: 094 * 095 */ 096 public class Controller extends PageFlowController 097 { 098 /** 099 * @jpf:action 100 * @jpf:forward name="formPage" path="formPage.jsp" 101 */ 102 public Forward begin() 103 { 104 return new Forward( "formPage" ); 105 } 106 107 /** 108 * @jpf:action 109 * @jpf:validation-error-forward name="failure" return-to="currentPage" 110 * @jpf:forward name="success" path="success.jsp" 111 */ 112 public Forward submitForm( MyForm form ) 113 { 114 return new Forward( "success" ); 115 } 116 117 /** 118 * @jpf:action 119 * @jpf:forward name="previousPageFlowBegin" return-action="begin" 120 */ 121 public Forward exit() 122 { 123 return new Forward( "previousPageFlowBegin" ); 124 } 125 126 /** 127 * This form bean uses the ValidatorPlugIn (rules are in /WEB-INF/strutsValidator-validation.xml). 128 */ 129 public static class MyForm extends org.apache.struts.validator.ValidatorForm 130 { 131 private String _email; 132 private String _age; 133 134 public String getEmail() 135 { 136 return _email; 137 } 138 139 public void setEmail( String email ) 140 { 141 _email = email; 142 } 143 144 public String getAge() 145 { 146 return _age; 147 } 148 149 public void setAge( String age ) 150 { 151 _age = age; 152 } 153 } 154 }`