1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.cubby.action;
17
18 import java.io.IOException;
19
20 import javax.servlet.RequestDispatcher;
21 import javax.servlet.ServletException;
22 import javax.servlet.http.HttpServletRequest;
23 import javax.servlet.http.HttpServletResponse;
24
25 import org.seasar.cubby.controller.ActionContext;
26 import org.seasar.cubby.util.CubbyUtils;
27 import org.seasar.framework.log.Logger;
28 import org.seasar.framework.util.StringUtil;
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54 public class Forward extends AbstractActionResult {
55
56 private static final Logger logger = Logger.getLogger(Forward.class);
57
58 private final String path;
59
60
61
62
63
64
65
66 public Forward(final String path) {
67 this.path = path;
68 }
69
70
71
72
73
74 public String getPath() {
75 return this.path;
76 }
77
78 public void execute(final ActionContext context,
79 final HttpServletRequest request, final HttpServletResponse response)
80 throws ServletException, IOException {
81 final Action action = context.getAction();
82 final String actionClassName = CubbyUtils.getActionClassName(context
83 .getComponentDef().getComponentClass());
84
85 final String absolutePath;
86 if (this.path.startsWith("/")) {
87 absolutePath = this.path;
88 } else if (StringUtil.isEmpty(actionClassName)) {
89 absolutePath = "/" + this.path;
90 } else {
91 absolutePath = "/" + actionClassName + "/" + this.path;
92 }
93 if (logger.isDebugEnabled()) {
94 logger.log("DCUB0001", new String[] { absolutePath });
95 }
96 final RequestDispatcher dispatcher = request
97 .getRequestDispatcher(absolutePath);
98 dispatcher.forward(request, response);
99 if (logger.isDebugEnabled()) {
100 logger.log("DCUB0002", new String[] { absolutePath });
101 }
102 action.postrender();
103
104 action.getFlash().clear();
105 }
106
107
108
109
110
111
112
113 @Override
114 public void prerender(final ActionContext context) {
115 final Action action = context.getAction();
116 action.prerender();
117 }
118
119 }