KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > verge > mvc > controller > actionflow > test > ActionHandler


1 /*
2  * Copyright (c) 2003, Inversoft
3  *
4  * This software is distribuable under the GNU Lesser General Public License.
5  * For more information visit gnu.org.
6  */

7 package com.inversoft.verge.mvc.controller.actionflow.test;
8
9
10 import com.inversoft.verge.mvc.controller.actionflow.ActionFlowAction;
11 import com.inversoft.verge.mvc.controller.actionflow.ActionFlowException;
12
13
14 /**
15  * This class is a ActionHandler for testing purposes
16  *
17  * @author Brian Pontarelli
18  */

19 public class ActionHandler {
20
21     public static boolean called;
22     public static boolean logoutCalled;
23     public static boolean step1;
24     public static boolean step2;
25
26
27     /**
28      * Constructs a new <code>ActionHandler</code>.
29      */

30     public ActionHandler() {
31         called = false;
32         logoutCalled = false;
33     }
34
35
36     /**
37      * Sets a boolean based on whether or not this method gets called
38      */

39     public Object JavaDoc handleLogin(ActionFlowAction state) {
40         called = true;
41         System.out.println("Handling login in ActionHandler");
42         return "success";
43     }
44
45     /**
46      * Sets a boolean based on whether or not this method gets called
47      */

48     public Object JavaDoc handleLogout(ActionFlowAction state) {
49         logoutCalled = true;
50         System.out.println("Handling logout in ActionHandler");
51         return "success";
52     }
53
54     /**
55      * Handles the failure action
56      */

57     public Object JavaDoc handleFailure(ActionFlowAction state) throws Exception JavaDoc {
58         called = true;
59         System.out.println("Handling failure in ActionHandler");
60         throw new Exception JavaDoc("Failure");
61     }
62
63     /**
64      * Handles the failure2 action
65      */

66     public Object JavaDoc handleFailure2(ActionFlowAction state) throws Exception JavaDoc {
67         called = true;
68         System.out.println("Handling failure2 in ActionHandler");
69         throw new ActionFlowException("Failure2");
70     }
71     
72     /**
73      * Handles the two step
74      */

75     public Object JavaDoc handleTwoStep(ActionFlowAction action) {
76         System.out.println("Handling twoStep");
77         step1 = true;
78         return "twoStepPartTwo";
79     }
80
81     /**
82      * Handles the two step part two
83      */

84     public Object JavaDoc handleTwoStepPartTwo(ActionFlowAction action) {
85         System.out.println("Handling twoStepPartTtwo");
86         step2 = true;
87         return "success";
88     }
89
90     /**
91      * Handles the three step
92      */

93     public Object JavaDoc handleThreeStep1(ActionFlowAction action) {
94         System.out.println("Handling threeStep1");
95         step1 = true;
96         return "threeStep2";
97     }
98
99     /**
100      * Handles the three step
101      */

102     public Object JavaDoc handleThreeStep2(ActionFlowAction action) {
103         System.out.println("Handling threeStep2");
104         step2 = true;
105         return "threeStep3";
106     }
107
108     /**
109      * Gets the value of called
110      */

111     public static boolean isCalled() {
112         return called;
113     }
114
115     /**
116      * Gets the value of called
117      */

118     public static boolean isLogoutCalled() {
119         return logoutCalled;
120     }
121 }
Popular Tags