I didnt include any example configuration files in
my previous post and I thought they might help. These are from the working
prototype.
I also didnt mention the error handling which Ive
added recently. The error handling is very powerful and allows the developer to
use an "action" made up of re-usable steps to handle errors. The error handlers
can be declared at the global level or at the pageflow or even action level and
can be "overridden" by handlers at lower scopes. I also forgot to mention that
anything at a lower scope "overrides" things at a higher scope. So if an action
is declared at the struts-config level it can be used anywhere in the app,
however if you also declare an action with the same name at the pageflow level
that one will be used in the declaring pageflow.
Paul T Smith
|
<?xml version="1.0" encoding="UTF-8"?> <!-- Created by psmith on April 18, 2002, 9:57 AM -->
<pageflow-application> <!-- configuration parameters --> <configuration> <set-property id="request-processor" property="" value=""/> <!-- set the steps used by the app initialization flow --> <request-processor-init-app> <step type="org.apache.struts.pageflow.engine.InitializeApplication"/> <step type="org.apache.struts.pageflow.engine.ExecuteApplication"/> </request-processor-init-app> <!-- set the steps used by the process request flow --> <request-processor-process-request> <step type="org.apache.struts.pageflow.engine.ProcessForm"/> <step type="org.apache.struts.pageflow.engine.ProcessValidation"/> <step type="org.apache.struts.pageflow.engine.ProcessAction"/> </request-processor-process-request> </configuration> <!-- Declare variables which can be used across the app. Only session and application scopes are valid, variables default to session scope. --> <variable-declarations> <variable name="test" type="java.lang.String" initialValue="testString" scope="session"/> <!-- dynamic types for "declared" complex objects. Good for wizards and such. --> <variable name="test2" type="org.apache.struts.utils.gdo.GDO"> <object> <attribute name="test" type="java.lang.String" value="Hello"/> <object name="testObj"> <attribute name="testLvl2" type="java.lang.Integer"/> </object> <list name="testObj"> <object> <attribute name="testLvl2" type="java.lang.Integer"/> </object> </list> <map name="testObj"> <object name="testMapEntry"> <attribute name="testLvl2" type="java.lang.Integer"/> </object> </map> </object> </variable> <variable name="testInt" type="java.lang.Integer" initialValue="2" scope="session"/> <variable name="name" type="java.lang.String" initialValue="Page3" scope="session"/> </variable-declarations> <!-- Filters which will run for the entire application. --> <filters> <filter type="test"></filter> </filters> <!-- Declare error handlers available for entire application. --> <error-handlers> <!-- An error handler has a name which can be referred to in other parts of the app --> <error-handler name="Application"> <action> <!-- Steps to execute for this error handler --> <steps> <step type="org.apache.struts.pageflow.core.SetDestinationStep"> <!-- Input parameters to the step. --> <parameters> <param name="destination" path="$engine/error/applicationError"/> </parameters> </step> <step type="org.apache.struts.pageflow.core.LogStep"> <parameters> <param name="msg" path="$engine/error/applicationError"/> <param name="msgDetail" path="$engine/error/getMessage()"/> </parameters> </step> </steps> </action> </error-handler> <error-handler name="test2" default="true"> <action> <steps> <step type="org.apache.struts.pageflow.core.SetDestinationStep"> <parameters> <param name="destination" value="ReturnToPage"/> </parameters> </step> <step type="org.apache.struts.pageflow.core.LogStep"> <parameters> <param name="msg" path="$engine/error/applicationError"/> <param name="msgDetail" path="$engine/error/message()"/> </parameters> </step> </steps> </action> </error-handler> </error-handlers> <!-- Global action declarations. --> <actions> <!-- Action defines a grouped set of functionality calable from a page. An action can be refered to by name. If it is available to all it is automatically available from every page --> <action name="end" availableToAll="true"> <steps> <step type="org.apache.struts.pageflow.core.SetDestinationStep"> <parameters> <param name="destination" value="Logout"/> </parameters> </step> <step type="org.apache.struts.pageflow.core.CustomStep"/> </steps> <!-- Custom filter to run before/after the action. --> <filters> <filter type=""></filter> </filters> <!-- If an error occurs during the action use the following error handler. --> <error-handler ref="test2"/> </action> </actions> <pages> <!-- Page defines a file on disk and the form object to use with it. --> <page name="Page1"> <locations> <location value="page1.jsp"/> </locations> <form-bean name="CustomPageForm" dynamic="true"> <form-property name="testField3" type="java.lang.String"/> <form-property name="testField4" type="java.lang.String"/> <form-property name="testField5" type="java.lang.String"/> </form-bean> </page> <page name="Page2"> <locations> <location value="page2.jsp"/> </locations> <form-bean name="CustomPageForm" dynamic="true"> <form-property name="testField3" type="java.lang.String"/> <form-property name="testField4" type="java.lang.String"/> <form-property name="testField5" type="java.lang.String"/> </form-bean> </page> <page name="Page3"> <locations> <location value="page3.jsp"/> </locations> <form-bean ref="TopLevelDynamicForm"/> </page> <page name="Logout"> <locations> <location value="logout.jsp"/> </locations> <form-bean ref="TopLevelDynamicForm"/> </page> <page name="Logon"> <locations> <location value="logon.jsp"></location> </locations> <form-bean ref="TopLevelDynamicForm"></form-bean> </page> </pages> <!-- Pageflows available for this web application. --> <pageflow-mappings> <pageflow name="test1" location="WEB-INF/test1-pageflow.xml"/> <pageflow name="test2" location="WEB-INF/test2-pageflow.xml"/> </pageflow-mappings> <!-- Forms are the same as previous. --> <forms> <form-bean name="TopLevelCustomForm" type="org.apache.struts.pageflow.CustomForm"/> <form-bean name="TopLevelDynamicForm" dynamic="true"> <form-property name="testField1" type="java.lang.String"/> <form-property name="testField2" type="java.lang.String"/> </form-bean> </forms> </pageflow-application>
<?xml version="1.0" encoding="UTF-8"?> <pageflow> <!-- Decalare any default error handlers for this pageflow. This will be used to capture and display errors associated with any sub-seciton of this pageflow. --> <error-handlers> <error-handler name="testErrorHandler" default="true"> <action> <steps> <step type="org.apache.struts.pageflow.core.SetDestinationStep"> <parameters> <param name="destination" value="$engine/error/applicationError"/> </parameters> </step> </steps> </action> </error-handler> <error-handler name="test2"> <action> <steps> <step type="org.apache.struts.pageflow.core.SetDestinationStep"> <parameters> <param name="destination" value="ReturnToPage"/> </parameters> </step> </steps> </action> </error-handler> </error-handlers> <!-- Decalare any variables which will live during the scope of this pageflow. Variables will be garbage collected if the pageflow goes out of scope. This happens when an action specifies exiting a pageflow, the user requests a standalone page outside of this pageflow or the session exits. --> <variable-declarations> <variable name="test" type="java.lang.String" initialValue="Test String"/> <variable name="count" type="java.lang.Integer" initialValue="2"/> <variable name="test1List" type="java.util.ArrayList" /> </variable-declarations> <!-- declare any filters which should run at the start for each call within this pageflow--> <filters> <filter type="org.apache.struts.pageflow.filter.CustomFilter"/> </filters> <actions> <action name="end"> <steps> <step type="org.apache.struts.pageflow.core.SetDestinationStep"> <parameters> <param name="destination" value="Page1"/> </parameters> </step> <step type="org.apache.struts.pageflow.core.test.CustomStep"/> <if> <expr><![CDATA[$pageflow/test == $var]]></expr> <steps> <step type="org.apache.struts.pageflow.core.SetDestinationStep"> <parameters> <param name="destination" value="PageB1"/> </parameters> </step> </steps> </if> </steps> <!-- declare any filters which should run at the start,end of this action --> <filters> <filter type="org.apache.struts.pageflow.filter.CustomFilter"/> </filters> <!-- declare a specialized error handler for this action --> </action> </actions> <flow> <!-- build a start point to provide access to the pageflow. A start is essentially an action which runs prior to the user getting to a page within the pageflow. There has to be at least one start per pageflow. A developer may specify a start as default which will force the system to use that start if a pageflow is requested without a specific start. --> <start name="start 1" isDefault="true" defaultDestination="Page1"> <action name="start"> <step type="org.apache.struts.pageflow.core.SetDestinationStep"> <parameters> <param name="destination" value="Page1"/> </parameters> </step> </action> </start> <!-- use instances to refer to a specific version of Page declaration. A page instance is basically a version of the default page. There may be many page instances for each page within a pageflow as long as they have seperate names. --> <page-instance ref="Page1" name="Page1"> <!-- form beans are essentially the same as in struts 1.1 except that they are transient. Since pageflow now manages memory for the developer, forms are no longer the default way of handling data. --> <form-mapping> <map name="testField3" value="testString"/> <map name="testField4" mapFrom="$pageflow/test"/> </form-mapping> <action name="end" defaultDestination="Logout"/> <action name="next"> <steps> <step type="org.apache.struts.pageflow.core.test.CustomStep"/> <step type="org.apache.struts.pageflow.core.SetDestinationStep"> <parameters> <param name="destination" value="PageC1"/> </parameters> </step> <step type="org.apache.struts.pageflow.core.PrintValueStep"> <parameters> <param name="value" value="$pageflow/test"/> <param name="destination" value="System.out"/> </parameters> </step> <step type="org.apache.struts.pageflow.core.PrintValueStep"> <parameters> <param name="value" value="$pageflow/test1List[$pageflow/count]"/> <param name="destination" value="Log"/> </parameters> </step> <if> <expr><![CDATA[$pageflow/test==2]]></expr> <steps> <step type="org.apache.struts.pageflow.core.SetDestinationStep"> <parameters> <param name="destination" value="Page2"/> </parameters> </step> </steps> </if> </steps> <filters> <filter type="org.apache.struts.pageflow.filter.CustomFilter"/> </filters> </action> </page-instance> <page-instance name="Page2" ref="Page2"> <action name="end"/> </page-instance> <page-instance name="Page2a" ref="Page2"> <action name="end"> <error-handler type="" output=""/> <steps> <step type="org.apache.struts.pageflow.core.SetDestinationStep"> <parameters> <param name="destination" value="Page3"/> </parameters> </step> </steps> </action> </page-instance> <page-instance name="Page3" ref="Page3"> <form-bean name="page3instance" dynamic="true"> <form-property name="test" type="String" /> </form-bean> <form-mapping> <map name="test" type="java.lang.String" value="testString"/> </form-mapping> <action name="end"/> <action name="next"> <error-handler type="" output=""/> <steps> <step type="org.apache.struts.pageflow.core.test.CustomStep"/> <!--<if> <expr><![CDATA[$test == $var3 && $var3 > 0 | $var3 < 10]]></expr> <commands> <destination value="PageB1"/> </commands> </if>--> </steps> </action> </page-instance> </flow> </pageflow>
<?xml version="1.0" encoding="UTF-8"?> <pageflow> <!-- Decalare any default error handlers for this pageflow. This will be used to capture and display errors associated with any sub-seciton of this pageflow. --> <error-handlers> <error-handler name="testErrorHandler" default="true"> <action> <steps> <step type="org.apache.struts.pageflow.core.SetDestinationStep"> <parameters> <param name="destination" value="$engine/error/applicationError"/> </parameters> </step> </steps> </action> </error-handler> <error-handler name="test2"> <action> <steps> <step type="org.apache.struts.pageflow.core.SetDestinationStep"> <parameters> <param name="destination" value="Return"/> </parameters> </step> </steps> </action> </error-handler> </error-handlers> <!-- Decalare any variables which will live during the scope of this pageflow. Variables will be garbage collected if the pageflow goes out of scope. This happens when an action specifies exiting a pageflow, the user requests a standalone page outside of this pageflow or the session exits. --> <variable-declarations> <variable name="test" type="java.lang.String" initialValue="Test String"/> <variable name="count" type="java.lang.Integer" initialValue="1"/> <variable name="test1List" type="java.util.ArrayList" /> </variable-declarations> <!-- declare any filters which should run at the start for each call within this pageflow--> <filters> <filter type="org.apache.struts.pageflow.filter.CustomFilter"/> </filters> <actions> <action name="end"> <steps> <step type="org.apache.struts.pageflow.core.SetDestinationStep"> <parameters> <param name="destination" value="Page1"/> </parameters> </step> <step type="org.apache.struts.pageflow.core.test.CustomStep"/> <if> <expr><![CDATA[$pageflow/test == $var]]></expr> <steps> <step type="org.apache.struts.pageflow.core.SetDestinationStep"> <parameters> <param name="destination" value="PageB1"/> </parameters> </step> </steps> </if> </steps> <!-- declare any filters which should run at the start,end of this action --> <filters> <filter type="org.apache.struts.pageflow.filter.CustomFilter"/> </filters> <!-- declare a specialized error handler for this action --> </action> </actions> <flow> <!-- build a start point to provide access to the pageflow. A start is essentially an action which runs prior to the user getting to a page within the pageflow. There has to be at least one start per pageflow. A developer may specify a start as default which will force the system to use that start if a pageflow is requested without a specific start. --> <start name="start1" isDefault="true" defaultDestination="Page1"> <action name="start"> <step type="org.apache.struts.pageflow.core.SetDestinationStep"> <parameters> <param name="destination" value="Page3"/> </parameters> </step> <step type="org.apache.struts.pageflow.core.SetVariableStep"> <parameters> <param name="variable1" value="$pageflow/test1List[1]"/> <param name="value1" value="testString"/> <param name="type1" value="java.lang.String"/> </parameters> </step> <step type="org.apache.struts.pageflow.core.LogStep"> <parameters> <param name="message" value="Hello From Start Action"/> <param name="priority" value="debug"/> </parameters> </step> </action> </start> <!-- use instances to refer to a specific version of Page declaration. A page instance is basically a version of the default page. There may be many page instances for each page within a pageflow as long as they have seperate names. --> <page-instance ref="Page1" name="Page1"> <!-- form beans are essentially the same as in struts 1.1 except that they are transient. Since pageflow now manages memory for the developer, forms are no longer the default way of handling data. A form mapping specifies the variable to get the value from and/or where to put the value automatically. --> <form-mapping> <map name="testField3" type="java.lang.String" value="testString"/> <map name="testField4" mapFrom="$pageflow/test"/> </form-mapping> <action name="end" defaultDestination="Logout"/> <action name="next"> <steps> <step type="org.apache.struts.pageflow.core.test.CustomStep"/> <step type="org.apache.struts.pageflow.core.SetDestinationStep"> <parameters> <param name="destination" value="Page2"/> </parameters> </step> <!--<if> <!-- if steps will use EL like script or javacript in the future. if steps are not functional in the prototype yet. --> <expr><![CDATA[$pageflow/count == 2]]></expr> <steps> <step type="org.apache.struts.pageflow.core.SetDestinationStep"> <parameters> <param name="destination" value="Page2"/> </parameters> </step> </steps> </if>--> </steps> <filters> <filter type="org.apache.struts.pageflow.filter.CustomFilter"/> </filters> </action> </page-instance> <page-instance name="Page2" ref="Page2"> <form-mapping> <map name="testField3" type="java.lang.String" value="testString"/> <map name="testField4" mapFrom="$pageflow/test" mapTo="$session/test2"/>/> </form-mapping> <action name="end"/> <action name="next"> <steps> <step type="org.apache.struts.pageflow.core.test.CustomStep"/> <step type="org.apache.struts.pageflow.core.SetDestinationStep"> <parameters> <param name="destination" value="Page3"/> </parameters> </step> </steps> </action> </page-instance> <page-instance name="Page2a" ref="Page2"> <action name="end"> <error-handler type="" output=""/> <steps> <step type="org.apache.struts.pageflow.core.SetDestinationStep"> <parameters> <param name="destination" value="Page3"/> </parameters> </step> </steps> </action> </page-instance> <page-instance name="Page3" ref="Page3"> <form-bean dynamic="true"> <form-property name="test" type="java.lang.String" /> <form-property name="test2" type="java.lang.String" /> </form-bean> <form-mapping> <map name="test" type="java.lang.String" value="testString"/> <map name="test2" mapFrom="$session/test"/> </form-mapping> <action name="end"/> <action name="next"> <steps> <step type="org.apache.struts.pageflow.core.test.CustomStep"/> <step type="org.apache.struts.pageflow.core.SetDestinationStep"> <parameters> <param name="destination" value="Page1"/> </parameters> </step> <step type="org.apache.struts.pageflow.core.LogStep"> <parameters> <param name="message" value="Hello From Next Action on Page 3"/> <param name="priority" value="debug"/> </parameters> </step> </steps> </action> </page-instance> </flow> </pageflow>
<?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/j2ee/dtds/web-app_2.3.dtd"> <web-app> <filter> <filter-name>PageFlow</filter-name> <filter-class> org.apach.struts.pageflow.PFActionFilter </filter-class> <init-param> <param-name>application-config</param-name> <param-value>/WEB-INF/pageflow-application.xml</param-value> </init-param> <init-param> <param-name>debug</param-name> <param-value>0</param-value> </init-param> <init-param> <param-name>detail</param-name> <param-value>0</param-value> </init-param> <init-param> <param-name>log4jfile</param-name> <param-value>/WEB-INF/log4j.xml</param-value> </init-param> </filter> <filter-mapping> <filter-name>PageFlow</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- Application Tag Library Descriptor --> <taglib> <taglib-uri>/WEB-INF/app.tld</taglib-uri> <taglib-location>/WEB-INF/app.tld</taglib-location> </taglib> <!-- Struts Tag Library Descriptors --> <taglib> <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri> <taglib-location>/WEB-INF/struts-bean.tld</taglib-location> </taglib> <taglib> <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri> <taglib-location>/WEB-INF/struts-html.tld</taglib-location> </taglib> <taglib> <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri> <taglib-location>/WEB-INF/struts-logic.tld</taglib-location> </taglib> </web-app>
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>