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