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.commons.chain.Command;
21 import org.apache.struts.chain.contexts.ActionContext;
22 import org.apache.struts.config.ForwardConfig;
23
24 /***
25 * <p>Look up and execute a commons-chain <code>Command</code> based on
26 * properties of the ActionContext's <code>forwardConfig</code> property.
27 * </p>
28 */
29 public class ExecuteForwardCommand extends ExecuteCommand {
30 /***
31 * <p>Return the command specified by the <code>command</code> and
32 * <code>catalog</code> properties of the <code>forwardConfig</code>
33 * property of the given <code>ActionContext</code>. If
34 * <code>forwardConfig</code> is null, return null.</p>
35 *
36 * @param context Our ActionContext
37 * @return Command to execute or null
38 */
39 protected Command getCommand(ActionContext context) {
40 ForwardConfig forwardConfig = context.getForwardConfig();
41
42 if (forwardConfig == null) {
43 return null;
44 }
45
46 return getCommand(forwardConfig.getCommand(), forwardConfig.getCatalog());
47 }
48
49 /***
50 * <p> Determine whether the forwardConfig should be processed. </p>
51 *
52 * @param context The ActionContext we are processing
53 * @return <p><code>true</code> if the given <code>ActionContext</code>
54 * has a non-null <code>forwardConfig</code> property.</p>
55 */
56 protected boolean shouldProcess(ActionContext context) {
57 return (context.getForwardConfig() != null);
58 }
59 }