1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.struts.chain.commands;
19
20 import org.apache.struts.action.Action;
21 import org.apache.struts.action.ActionForm;
22 import org.apache.struts.chain.contexts.ActionContext;
23 import org.apache.struts.config.ActionConfig;
24 import org.apache.struts.config.ForwardConfig;
25
26 /***
27 * <p>Invoke the appropriate <code>Action</code> for this request, and cache
28 * the returned <code>ActionForward</code>.</p>
29 *
30 * @version $Rev: 421119 $ $Date: 2005-06-04 10:58:46 -0400 (Sat, 04 Jun 2005)
31 * $
32 */
33 public abstract class AbstractExecuteAction extends ActionCommandBase {
34
35
36 /***
37 * <p>Invoke the appropriate <code>Action</code> for this request, and
38 * cache the returned <code>ActionForward</code>.</p>
39 *
40 * @param actionCtx The <code>Context</code> for the current request
41 * @return <code>false</code> so that processing continues
42 * @throws Exception if thrown by the Action class
43 */
44 public boolean execute(ActionContext actionCtx)
45 throws Exception {
46
47 Boolean valid = actionCtx.getFormValid();
48
49 if ((valid == null) || !valid.booleanValue()) {
50 return (false);
51 }
52
53
54 Action action = actionCtx.getAction();
55
56 if (action == null) {
57 return (false);
58 }
59
60 ActionConfig actionConfig = actionCtx.getActionConfig();
61 ActionForm actionForm = actionCtx.getActionForm();
62
63
64 ForwardConfig forwardConfig =
65 execute(actionCtx, action, actionConfig, actionForm);
66
67 actionCtx.setForwardConfig(forwardConfig);
68
69 return (false);
70 }
71
72
73
74 /***
75 * <p>Execute the specified <code>Action</code>, and return the resulting
76 * <code>ForwardConfig</code>.</p>
77 *
78 * @param context The <code>Context</code> for this request
79 * @param action The <code>Action</code> to be executed
80 * @param actionConfig The <code>ActionConfig</code> defining this action
81 * @param actionForm The <code>ActionForm</code> (if any) for this
82 * action
83 * @return ForwardConfig The next location, or null
84 * @throws Exception if thrown by the <code>Action</code>
85 */
86 protected abstract ForwardConfig execute(ActionContext context,
87 Action action, ActionConfig actionConfig, ActionForm actionForm)
88 throws Exception;
89 }