ControllerFileNavigationController.jpf Sample

This topic inludes the source code for the ControllerFileNavigationController.jpf Sample.

Sample Location

This sample is located in the following directory in your WebLogic Workshop installation:

BEA_HOME/weblogic81/samples/workshop/SamplesApp/WebApp/navigation/controllerFileNavigation/

Sample Source Code


001 package navigation.controllerFileNavigation;
002 
003 import com.bea.wlw.netui.pageflow.Forward;
004 import com.bea.wlw.netui.pageflow.PageFlowController;
005 import org.apache.struts.action.ActionForm;
006 
007 /** @jpf:controller nested="true"
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:/navigation/controllerFileNavigation/controllerFileNavigationController.jpf"/>
012  <pageflow-object id="action:begin.do">
013  *   <property value="60" name="x"/>
014  *   <property value="60" name="y"/>
015  </pageflow-object>
016  <pageflow-object id="action:done.do">
017  *   <property value="180" name="x"/>
018  *   <property value="200" name="y"/>
019  </pageflow-object>
020  <pageflow-object id="action:ThisWeeksSpecial.do">
021  *   <property value="300" name="x"/>
022  *   <property value="60" name="y"/>
023  </pageflow-object>
024  <pageflow-object id="action-call:@page:index.jsp@#@action:done.do@">
025  *   <property value="180,180,180,180" name="elbowsX"/>
026  *   <property value="104,130,130,156" name="elbowsY"/>
027  *   <property value="South_1" name="fromPort"/>
028  *   <property value="North_1" name="toPort"/>
029  </pageflow-object>
030  <pageflow-object id="action-call:@page:index.jsp@#@action:ThisWeeksSpecial.do@">
031  *   <property value="216,240,240,264" name="elbowsX"/>
032  *   <property value="52,52,52,52" name="elbowsY"/>
033  *   <property value="East_1" name="fromPort"/>
034  *   <property value="West_1" name="toPort"/>
035  </pageflow-object>
036  <pageflow-object id="page:index.jsp">
037  *   <property value="180" name="x"/>
038  *   <property value="60" name="y"/>
039  </pageflow-object>
040  <pageflow-object id="page:error.jsp">
041  *   <property value="180" name="x"/>
042  *   <property value="300" name="y"/>
043  </pageflow-object>
044  <pageflow-object id="action-call:@page:kayaking.jsp@#@action:done.do@">
045  *   <property value="264,240,240,216" name="elbowsX"/>
046  *   <property value="152,152,192,192" name="elbowsY"/>
047  *   <property value="West_1" name="fromPort"/>
048  *   <property value="East_1" name="toPort"/>
049  </pageflow-object>
050  <pageflow-object id="page:kayaking.jsp">
051  *   <property value="300" name="x"/>
052  *   <property value="160" name="y"/>
053  </pageflow-object>
054  <pageflow-object id="action-call:@page:sailing.jsp@#@action:done.do@">
055  *   <property value="264,240,240,216" name="elbowsX"/>
056  *   <property value="252,252,203,203" name="elbowsY"/>
057  *   <property value="West_1" name="fromPort"/>
058  *   <property value="East_2" name="toPort"/>
059  </pageflow-object>
060  <pageflow-object id="page:sailing.jsp">
061  *   <property value="300" name="x"/>
062  *   <property value="260" name="y"/>
063  </pageflow-object>
064  <pageflow-object id="forward:path#success#index.jsp#@action:begin.do@">
065  *   <property value="52,52,52,52" name="elbowsY"/>
066  *   <property value="96,120,120,144" name="elbowsX"/>
067  *   <property value="West_1" name="toPort"/>
068  *   <property value="East_1" name="fromPort"/>
069  *   <property value="success" name="label"/>
070  </pageflow-object>
071  <pageflow-object id="exit:begin">
072  *   <property value="60" name="x"/>
073  *   <property value="200" name="y"/>
074  </pageflow-object>
075  <pageflow-object id="forward:return-action#done#begin#@action:done.do@">
076  *   <property value="144,120,120,96" name="elbowsX"/>
077  *   <property value="192,192,192,192" name="elbowsY"/>
078  *   <property value="West_1" name="fromPort"/>
079  *   <property value="East_1" name="toPort"/>
080  *   <property value="done" name="label"/>
081  </pageflow-object>
082  <pageflow-object id="forward:path#success#kayaking.jsp#@action:ThisWeeksSpecial.do@">
083  *   <property value="104,110,110,116" name="elbowsY"/>
084  *   <property value="300,300,300,300" name="elbowsX"/>
085  *   <property value="North_1" name="toPort"/>
086  *   <property value="South_1" name="fromPort"/>
087  *   <property value="success" name="label"/>
088  </pageflow-object>
089  </view-properties>
090  * ::
091  *  */
092 public class controllerFileNavigationController extends PageFlowController
093 {
094 
095     /**
096      * @jpf:action
097      * @jpf:forward name="success" path="index.jsp"
098      */
099     protected Forward begin()
100     {
101         return new Forward"success" );
102     }
103 
104     /**
105      * If the user runs this nested page flow independently of its nesting page flow 
106      * (SamplesApp/WebApp/Controller.jpf) and attempts to return to the 
107      * nesting page flow, she will receive an EmptyNestingStackException.
108      
109      * The jpf:catch annotation below handles this exception and tells the user how to 
110      * recover from the error.
111      
112      * @jpf:action
113      * @jpf:forward name="done" return-action="begin"
114      * @jpf:catch method="handleError" type="com.bea.wlw.netui.pageflow.EmptyNestingStackException"
115      */
116     public Forward done()
117     {
118         return new Forward"done" );
119     }
120 
121     /**
122      * This method is called when a user receives an EmptyNestingStackExpection.
123      
124      * @jpf:exception-handler
125      * @jpf:forward name="error" path="error.jsp"
126      */
127     public Forward handleErrorException e, String msg, String msgKey, ActionForm form )
128     {
129         getRequest().setAttribute("e", e.toString());
130         return new Forward "error" );
131     }
132 
133     
134     /**
135      * This method forwards to the JSP identified in the path
136      * attribute of the forward annotation. Instead of 
137      * hard-coding the destination in presentation-layer JSP
138      * files, navigation control is set in this file, the 
139      * Page Flow's controller class. In this simple example, 
140      * you can update the ThisWeeksSpecial target by changing
141      * (for example) path="kayaking.jsp" to path="sailing.jsp"
142      
143      * @jpf:action
144      * @jpf:forward name="success" path="kayaking.jsp"
145      */
146     public Forward ThisWeeksSpecial()
147     {
148         return new Forward"success" );
149     }  
150     
151 }