# 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/messageDriven/

## Sample Source Code

`001 package messageDriven; 002 import com.bea.wlw.netui.pageflow.Forward; 003 import com.bea.wlw.netui.pageflow.PageFlowController; 004 import java.util.Collection; 005 import javax.ejb.FinderException; 006 import javax.jms.JMSException; 007 008 /** 009 * @jpf:controller 010 * @jpf:view-properties view-properties:: 011 * <!-- This data is auto-generated. Hand-editing this section is not recommended. --> 012 * <view-properties> 013 * <pageflow-object id="pageflow:/messageDriven/Controller.jpf"/> 014 * <pageflow-object id="action:begin.do"> 015 * <property value="60" name="x"/> 016 * <property value="240" name="y"/> 017 * </pageflow-object> 018 * <pageflow-object id="action:refreshPage.do"> 019 * <property value="260" name="x"/> 020 * <property value="80" name="y"/> 021 * </pageflow-object> 022 * <pageflow-object id="action:refreshPageOrdered.do"> 023 * <property value="80" name="x"/> 024 * <property value="140" name="y"/> 025 * </pageflow-object> 026 * <pageflow-object id="action:addViaQueue.do"> 027 * <property value="400" name="x"/> 028 * <property value="240" name="y"/> 029 * </pageflow-object> 030 * <pageflow-object id="action:addViaTopic.do"> 031 * <property value="400" name="x"/> 032 * <property value="120" name="y"/> 033 * </pageflow-object> 034 * <pageflow-object id="action:deleteViaQueue.do"> 035 * <property value="260" name="x"/> 036 * <property value="280" name="y"/> 037 * </pageflow-object> 038 * <pageflow-object id="action-call:@page:index.jsp@#@action:addViaQueue.do@"> 039 * <property value="296,330,330,364" name="elbowsX"/> 040 * <property value="172,172,232,232" name="elbowsY"/> 041 * <property value="East_1" name="fromPort"/> 042 * <property value="West_1" name="toPort"/> 043 * </pageflow-object> 044 * <pageflow-object id="action-call:@page:index.jsp@#@action:refreshPageOrdered.do@"> 045 * <property value="224,170,170,116" name="elbowsX"/> 046 * <property value="161,161,132,132" name="elbowsY"/> 047 * <property value="West_0" name="fromPort"/> 048 * <property value="East_1" name="toPort"/> 049 * </pageflow-object> 050 * <pageflow-object id="action-call:@page:index.jsp@#@action:addViaTopic.do@"> 051 * <property value="296,330,330,364" name="elbowsX"/> 052 * <property value="172,172,112,112" name="elbowsY"/> 053 * <property value="East_1" name="fromPort"/> 054 * <property value="West_1" name="toPort"/> 055 * </pageflow-object> 056 * <pageflow-object id="action-call:@page:index.jsp@#@action:deleteViaQueue.do@"> 057 * <property value="260,260,260,260" name="elbowsX"/> 058 * <property value="224,230,230,236" name="elbowsY"/> 059 * <property value="South_1" name="fromPort"/> 060 * <property value="North_1" name="toPort"/> 061 * </pageflow-object> 062 * <pageflow-object id="action-call:@page:index.jsp@#@action:refreshPage.do@"> 063 * <property value="260,260,260,260" name="elbowsX"/> 064 * <property value="136,130,130,124" name="elbowsY"/> 065 * <property value="North_1" name="fromPort"/> 066 * <property value="South_1" name="toPort"/> 067 * </pageflow-object> 068 * <pageflow-object id="page:index.jsp"> 069 * <property value="260" name="x"/> 070 * <property value="180" name="y"/> 071 * </pageflow-object> 072 * <pageflow-object id="forward:path#success#index.jsp#@action:begin.do@"> 073 * <property value="96,160,160,224" name="elbowsX"/> 074 * <property value="232,232,172,172" 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="return-to:@forward:return-to#success#currentPage#@action:refreshPage.do@@"> 080 * <property value="180" name="x"/> 081 * <property value="80" name="y"/> 082 * </pageflow-object> 083 * <pageflow-object id="forward:return-to#success#currentPage#@action:refreshPage.do@"> 084 * <property value="224,220,220,216" name="elbowsX"/> 085 * <property value="72,72,72,72" name="elbowsY"/> 086 * <property value="West_1" name="fromPort"/> 087 * <property value="East_1" name="toPort"/> 088 * <property value="success" name="label"/> 089 * </pageflow-object> 090 * <pageflow-object id="return-to:@forward:return-to#success#currentPage#@action:refreshPageOrdered.do@@"> 091 * <property value="80" name="x"/> 092 * <property value="40" name="y"/> 093 * </pageflow-object> 094 * <pageflow-object id="forward:return-to#success#currentPage#@action:refreshPageOrdered.do@"> 095 * <property value="80,80,80,80" name="elbowsX"/> 096 * <property value="96,90,90,84" name="elbowsY"/> 097 * <property value="North_1" name="fromPort"/> 098 * <property value="South_1" name="toPort"/> 099 * <property value="success" name="label"/> 100 * </pageflow-object> 101 * <pageflow-object id="return-to:@forward:return-to#success#currentPage#@action:addViaQueue.do@@"> 102 * <property value="520" name="x"/> 103 * <property value="240" name="y"/> 104 * </pageflow-object> 105 * <pageflow-object id="forward:return-to#success#currentPage#@action:addViaQueue.do@"> 106 * <property value="436,460,460,484" name="elbowsX"/> 107 * <property value="232,232,232,232" name="elbowsY"/> 108 * <property value="East_1" name="fromPort"/> 109 * <property value="West_1" name="toPort"/> 110 * <property value="success" name="label"/> 111 * </pageflow-object> 112 * <pageflow-object id="return-to:@forward:return-to#success#currentPage#@action:addViaTopic.do@@"> 113 * <property value="520" name="x"/> 114 * <property value="120" name="y"/> 115 * </pageflow-object> 116 * <pageflow-object id="forward:return-to#success#currentPage#@action:addViaTopic.do@"> 117 * <property value="436,460,460,484" name="elbowsX"/> 118 * <property value="112,112,112,112" name="elbowsY"/> 119 * <property value="East_1" name="fromPort"/> 120 * <property value="West_1" name="toPort"/> 121 * <property value="success" name="label"/> 122 * </pageflow-object> 123 * <pageflow-object id="return-to:@forward:return-to#success#currentPage#@action:deleteViaQueue.do@@"> 124 * <property value="140" name="x"/> 125 * <property value="320" name="y"/> 126 * </pageflow-object> 127 * <pageflow-object id="forward:return-to#success#currentPage#@action:deleteViaQueue.do@"> 128 * <property value="224,200,200,176" name="elbowsX"/> 129 * <property value="272,272,312,312" name="elbowsY"/> 130 * <property value="West_1" name="fromPort"/> 131 * <property value="East_1" name="toPort"/> 132 * <property value="success" name="label"/> 133 * </pageflow-object> 134 * <pageflow-object id="control:messageDriven.FacadeBeanControl#facadeBeanControl"> 135 * <property value="53" name="x"/> 136 * <property value="34" name="y"/> 137 * </pageflow-object> 138 * <pageflow-object id="control:messageDriven.MessageSender#messageSender"> 139 * <property value="46" name="x"/> 140 * <property value="34" name="y"/> 141 * </pageflow-object> 142 * </view-properties> 143 * :: 144 */ 145 public class Controller extends PageFlowController 146 { 147 /** 148 * @common:control 149 */ 150 private messageDriven.FacadeBeanControl facadeBeanControl; 151 152 153 /** 154 * @common:control 155 */ 156 private messageDriven.MessageSender messageSender; 157 158 public transient Collection allTokens; 159 160 // Uncomment this declaration to access Global.app. 161 // 162 // protected global.Global globalApp; 163 // 164 165 // For an example of page flow exception handling see the example "catch" and "exception-handler" 166 // annotations in {project}/WEB-INF/src/global/Global.app 167 168 /** 169 * This method represents the point of entry into the pageflow 170 * @jpf:action 171 * @jpf:forward name="success" path="index.jsp" 172 */ 173 protected Forward begin() throws FinderException 174 { 175 allTokens = facadeBeanControl.findAllTokens(); 176 return new Forward("success"); 177 } 178 179 /** 180 * @jpf:action 181 * @jpf:forward name="success" return-to="currentPage" 182 */ 183 protected Forward refreshPage() throws FinderException 184 { 185 allTokens = facadeBeanControl.findAllTokens(); 186 return new Forward("success"); 187 } 188 189 /** 190 * @jpf:action 191 * @jpf:forward name="success" return-to="currentPage" 192 */ 193 protected Forward refreshPageOrdered() throws FinderException 194 { 195 allTokens = facadeBeanControl.findAllTokensOrdered(); 196 return new Forward("success"); 197 } 198 199 /** 200 * @jpf:action 201 * @jpf:forward name="success" return-to="currentPage" 202 */ 203 protected Forward addViaQueue() throws FinderException, JMSException 204 { 205 messageSender.add20ViaQueue(allTokens.size()); 206 return new Forward("success"); 207 } 208 209 /** 210 * @jpf:action 211 * @jpf:forward name="success" return-to="currentPage" 212 */ 213 protected Forward addViaTopic() throws FinderException, JMSException 214 { 215 messageSender.add20ViaTopic(allTokens.size()); 216 return new Forward("success"); 217 } 218 219 /** 220 * @jpf:action 221 * @jpf:forward name="success" return-to="currentPage" 222 */ 223 protected Forward deleteViaQueue() throws FinderException, JMSException 224 { 225 messageSender.deleteAllViaQueue(); 226 return new Forward("success"); 227 } 228 229 }`