# 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/EJBs_ClientApps/valueObject/

## Sample Source Code

`001 package valueObject; 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 finderMethods.ManufacturerVO; 006 import java.rmi.RemoteException; 007 import java.util.ArrayList; 008 import java.util.Collection; 009 010 /** 011 * @jpf:controller 012 * @jpf:view-properties view-properties:: 013 * <!-- This data is auto-generated. Hand-editing this section is not recommended. --> 014 * <view-properties> 015 * <pageflow-object id="pageflow:/valueObject/Controller.jpf"/> 016 * <pageflow-object id="action:begin.do"> 017 * <property value="100" name="x"/> 018 * <property value="280" name="y"/> 019 * </pageflow-object> 020 * <pageflow-object id="action:toNewManufacturer.do"> 021 * <property value="360" name="x"/> 022 * <property value="280" name="y"/> 023 * </pageflow-object> 024 * <pageflow-object id="action:addNewManufacturer.do#valueObject.Controller.AddNewManufacturerForm"> 025 * <property value="220" name="x"/> 026 * <property value="420" name="y"/> 027 * </pageflow-object> 028 * <pageflow-object id="action:showItemsManufacturer.do"> 029 * <property value="360" name="x"/> 030 * <property value="200" name="y"/> 031 * </pageflow-object> 032 * <pageflow-object id="action:backToIndex.do"> 033 * <property value="220" name="x"/> 034 * <property value="60" name="y"/> 035 * </pageflow-object> 036 * <pageflow-object id="action-call:@page:index.jsp@#@action:toNewManufacturer.do@"> 037 * <property value="256,290,290,324" name="elbowsX"/> 038 * <property value="252,252,272,272" name="elbowsY"/> 039 * <property value="East_1" name="fromPort"/> 040 * <property value="West_1" name="toPort"/> 041 * </pageflow-object> 042 * <pageflow-object id="action-call:@page:index.jsp@#@action:showItemsManufacturer.do@"> 043 * <property value="256,290,290,324" name="elbowsX"/> 044 * <property value="252,252,192,192" name="elbowsY"/> 045 * <property value="East_1" name="fromPort"/> 046 * <property value="West_1" name="toPort"/> 047 * </pageflow-object> 048 * <pageflow-object id="page:index.jsp"> 049 * <property value="220" name="x"/> 050 * <property value="260" name="y"/> 051 * </pageflow-object> 052 * <pageflow-object id="action-call:@page:newManufacturer.jsp@#@action:addNewManufacturer.do#valueObject.Controller.AddNewManufacturerForm@"> 053 * <property value="324,290,290,256" name="elbowsX"/> 054 * <property value="412,412,412,412" name="elbowsY"/> 055 * <property value="West_1" name="fromPort"/> 056 * <property value="East_1" name="toPort"/> 057 * </pageflow-object> 058 * <pageflow-object id="page:newManufacturer.jsp"> 059 * <property value="360" name="x"/> 060 * <property value="420" name="y"/> 061 * </pageflow-object> 062 * <pageflow-object id="action-call:@page:itemsManufacturer.jsp@#@action:backToIndex.do@"> 063 * <property value="324,290,290,256" name="elbowsX"/> 064 * <property value="52,52,52,52" name="elbowsY"/> 065 * <property value="West_1" name="fromPort"/> 066 * <property value="East_1" name="toPort"/> 067 * </pageflow-object> 068 * <pageflow-object id="page:itemsManufacturer.jsp"> 069 * <property value="360" name="x"/> 070 * <property value="60" name="y"/> 071 * </pageflow-object> 072 * <pageflow-object id="forward:path#success#index.jsp#@action:begin.do@"> 073 * <property value="136,160,160,184" name="elbowsX"/> 074 * <property value="272,272,252,252" name="elbowsY"/> 075 * <property value="East_1" name="fromPort"/> 076 * <property value="West_1" name="toPort"/> 077 * <property value="success" name="label"/> 078 * </pageflow-object> 079 * <pageflow-object id="forward:path#success#newManufacturer.jsp#@action:toNewManufacturer.do@"> 080 * <property value="360,360,360,360" name="elbowsX"/> 081 * <property value="324,350,350,376" name="elbowsY"/> 082 * <property value="South_1" name="fromPort"/> 083 * <property value="North_1" name="toPort"/> 084 * <property value="success" name="label"/> 085 * </pageflow-object> 086 * <pageflow-object id="forward:path#success#index.jsp#@action:addNewManufacturer.do#valueObject.Controller.AddNewManufacturerForm@"> 087 * <property value="220,220,220,220" name="elbowsX"/> 088 * <property value="376,340,340,304" name="elbowsY"/> 089 * <property value="North_1" name="fromPort"/> 090 * <property value="South_1" name="toPort"/> 091 * <property value="success" name="label"/> 092 * </pageflow-object> 093 * <pageflow-object id="forward:path#success#itemsManufacturer.jsp#@action:showItemsManufacturer.do@"> 094 * <property value="360,360,360,360" name="elbowsX"/> 095 * <property value="156,130,130,104" name="elbowsY"/> 096 * <property value="North_1" name="fromPort"/> 097 * <property value="South_1" name="toPort"/> 098 * <property value="success" name="label"/> 099 * </pageflow-object> 100 * <pageflow-object id="forward:path#success#index.jsp#@action:backToIndex.do@"> 101 * <property value="220,220,220,220" name="elbowsX"/> 102 * <property value="104,160,160,216" name="elbowsY"/> 103 * <property value="South_1" name="fromPort"/> 104 * <property value="North_1" name="toPort"/> 105 * <property value="success" name="label"/> 106 * </pageflow-object> 107 * <pageflow-object id="control:valueObject.AdminBeanControl#adminBeanControl"> 108 * <property value="52" name="x"/> 109 * <property value="34" name="y"/> 110 * </pageflow-object> 111 * <pageflow-object id="formbeanprop:valueObject.Controller.AddNewManufacturerForm#name#java.lang.String"/> 112 * <pageflow-object id="formbeanprop:valueObject.Controller.AddNewManufacturerForm#usManufacturer#java.lang.Integer"/> 113 * <pageflow-object id="formbeanprop:valueObject.Controller.AddNewManufacturerForm#listnumber#java.lang.Integer"/> 114 * <pageflow-object id="formbean:valueObject.Controller.AddNewManufacturerForm"/> 115 * </view-properties> 116 * :: 117 */ 118 public class Controller extends PageFlowController 119 { 120 /** 121 * @common:control 122 */ 123 private valueObject.AdminBeanControl adminBeanControl; 124 125 public transient Collection manufacturers; 126 public transient ManufacturerVO mVO; 127 128 // Uncomment this declaration to access Global.app. 129 // 130 // protected global.Global globalApp; 131 // 132 133 // For an example of page flow exception handling see the example "catch" and "exception-handler" 134 // annotations in {project}/WEB-INF/src/global/Global.app 135 136 /** 137 * This method represents the point of entry into the pageflow 138 * @jpf:action 139 * @jpf:forward name="success" path="index.jsp" 140 */ 141 protected Forward begin() throws RemoteException 142 { 143 manufacturers = adminBeanControl.getManufacturersVO(); 144 return new Forward("success"); 145 } 146 147 /** 148 * @jpf:action 149 * @jpf:forward name="success" path="newManufacturer.jsp" 150 */ 151 protected Forward toNewManufacturer() 152 { 153 return new Forward("success"); 154 } 155 156 /** 157 * @jpf:action 158 * @jpf:forward name="success" path="index.jsp" 159 */ 160 protected Forward addNewManufacturer(AddNewManufacturerForm form) throws RemoteException 161 { 162 mVO = new ManufacturerVO(null,form.getListnumber(), form.getName(),form.getUsManufacturer().intValue()); 163 adminBeanControl.addManufacturerVO(mVO); 164 manufacturers.add(mVO); 165 return new Forward("success"); 166 } 167 168 /** 169 * @jpf:action 170 * @jpf:forward name="success" path="itemsManufacturer.jsp" 171 */ 172 protected Forward showItemsManufacturer() throws RemoteException 173 { Integer PK = new Integer(getRequest().getParameter("manufacturerPK")); 174 mVO = adminBeanControl.getManufacturer(PK); 175 return new Forward("success"); 176 } 177 178 /** 179 * @jpf:action 180 * @jpf:forward name="success" path="index.jsp" 181 */ 182 protected Forward backToIndex() 183 { 184 return new Forward("success"); 185 } 186 187 public String getBooleanValue(int booleanInt) { 188 if(booleanInt == 0) 189 return "No"; 190 else 191 return "Yes"; 192 } 193 194 /** 195 * FormData get and set methods may be overwritten by the Form Bean editor. 196 */ 197 public static class AddNewManufacturerForm extends FormData 198 { 199 private Integer listnumber; 200 201 private Integer usManufacturer; 202 203 private String name; 204 205 public void setName(String name) 206 { 207 this.name = name; 208 } 209 210 public String getName() 211 { 212 return this.name; 213 } 214 215 public void setUsManufacturer(Integer usManufacturer) 216 { 217 this.usManufacturer = usManufacturer; 218 } 219 220 public Integer getUsManufacturer() 221 { 222 return this.usManufacturer; 223 } 224 225 public void setListnumber(Integer listnumber) 226 { 227 this.listnumber = listnumber; 228 } 229 230 public Integer getListnumber() 231 { 232 return this.listnumber; 233 } 234 } 235 }`