1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.apache.struts2.portlet.dispatcher;
23
24 import com.opensymphony.xwork2.Action;
25
26 import java.io.Serializable;
27 import java.util.Map;
28
29 import org.apache.struts2.interceptor.SessionAware;
30 import org.apache.struts2.portlet.PortletActionConstants;
31
32 /***
33 * When a portlet is targetted for an <code>event</code>, the portlet will receive two
34 * portlet requests, one for the <code>event</code> phase, and then followed by a <code>render</code>
35 * operation. When in the <code>event</code> phase, the action that is executed can't render
36 * any output. This means that if an action in the XWork configuration is executed in the event
37 * phase, and the action is set up with a result that should render something, the result can't
38 * immediately be executed. The portlet needs to "wait" to the render phase to do the
39 * rendering.
40 * <p/>
41 * When the {@link org.apache.struts2.portlet.result.PortletResult} detects such a
42 * scenario, instead of executing the actual view, it prepares a couple of render parameters
43 * specifying this action and the location of the view, which then will be executed in the
44 * following render request.
45 */
46 public class DirectRenderFromEventAction implements SessionAware, PortletActionConstants, Action, Serializable {
47
48 private static final long serialVersionUID = -1814807772308405785L;
49
50 private String location = null;
51
52 /***
53 * Get the location of the view.
54 *
55 * @return Returns the location.
56 */
57 public String getLocation() {
58 return location;
59 }
60
61 /***
62 * Always return success.
63 *
64 * @return SUCCESS
65 */
66 public String execute() throws Exception {
67 return SUCCESS;
68 }
69
70 public void setSession(Map session) {
71 location = (String)session.get(RENDER_DIRECT_LOCATION);
72 }
73 }