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