View Javadoc

1   /*
2    * $Id: DirectRenderFromEventAction.java 442897 2006-09-13 08:43:37Z hermanns $
3    *
4    * Copyright 2006 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.struts2.portlet.dispatcher;
19  
20  import com.opensymphony.xwork2.Action;
21  
22  import java.io.Serializable;
23  
24  /***
25   * When a portlet is targetted for an <code>event</code>, the portlet will receive two
26   * portlet requests, one for the <code>event</code> phase, and then followed by a <code>render</code>
27   * operation. When in the <code>event</code> phase, the action that is executed can't render
28   * any output. This means that if an action in the XWork configuration is executed in the event
29   * phase, and the action is set up with a result that should render something, the result can't
30   * immediately be executed. The portlet needs to "wait" to the render phase to do the
31   * rendering.
32   * <p/>
33   * When the {@link org.apache.struts2.portlet.result.PortletResult} detects such a
34   * scenario, instead of executing the actual view, it prepares a couple of render parameters
35   * specifying this action and the location of the view, which then will be executed in the
36   * following render request.
37   */
38  public class DirectRenderFromEventAction implements Action, Serializable {
39  
40      private static final long serialVersionUID = -1814807772308405785L;
41  
42      private String location = null;
43  
44      /***
45       * Get the location of the view.
46       *
47       * @return Returns the location.
48       */
49      public String getLocation() {
50          return location;
51      }
52  
53      /***
54       * Set the location of the view.
55       *
56       * @param location The location to set.
57       */
58      public void setLocation(String location) {
59          this.location = location;
60      }
61  
62      /***
63       * Always return success.
64       *
65       * @return SUCCESS
66       */
67      public String execute() throws Exception {
68          return SUCCESS;
69      }
70  }