Portlet sample application doesn't work

o patches applied

Issue Number: WW-1407

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@442897 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Rainer Hermanns
2006-09-13 08:43:37 +00:00
parent f1d30549c5
commit 3432ab2a85
2 changed files with 35 additions and 24 deletions
@@ -17,32 +17,33 @@
*/
package org.apache.struts2.portlet.dispatcher;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.Action;
import java.io.Serializable;
/**
* When a portlet is targetted for an <code>event</code>, the portlet will receive two
* When a portlet is targetted for an <code>event</code>, the portlet will receive two
* portlet requests, one for the <code>event</code> phase, and then followed by a <code>render</code>
* operation. When in the <code>event</code> phase, the action that is executed can't render
* any output. This means that if an action in the XWork configuration is executed in the event
* phase, and the action is set up with a result that should render something, the result can't
* immediately be executed. The portlet needs to "wait" to the render phase to do the
* rendering.
*
* When the {@link org.apache.struts2.portlet.result.PortletResult} detects such a
* any output. This means that if an action in the XWork configuration is executed in the event
* phase, and the action is set up with a result that should render something, the result can't
* immediately be executed. The portlet needs to "wait" to the render phase to do the
* rendering.
* <p/>
* When the {@link org.apache.struts2.portlet.result.PortletResult} detects such a
* scenario, instead of executing the actual view, it prepares a couple of render parameters
* specifying this action and the location of the view, which then will be executed in the
* specifying this action and the location of the view, which then will be executed in the
* following render request.
*
*/
public class DirectRenderFromEventAction extends ActionSupport {
private static final long serialVersionUID = -1814807772308405785L;
private String location = null;
public class DirectRenderFromEventAction implements Action, Serializable {
private static final long serialVersionUID = -1814807772308405785L;
private String location = null;
/**
* Get the location of the view.
*
*
* @return Returns the location.
*/
public String getLocation() {
@@ -51,10 +52,19 @@ public class DirectRenderFromEventAction extends ActionSupport {
/**
* Set the location of the view.
*
*
* @param location The location to set.
*/
public void setLocation(String location) {
this.location = location;
}
/**
* Always return success.
*
* @return SUCCESS
*/
public String execute() throws Exception {
return SUCCESS;
}
}
@@ -238,7 +238,7 @@ public class Jsr168Dispatcher extends GenericPortlet implements StrutsStatics,
}
}
dispatcherUtils = new Dispatcher(null);
dispatcherUtils = new Dispatcher(ServletContextHolderListener.getServletContext());
}
/**
@@ -279,14 +279,13 @@ public class Jsr168Dispatcher extends GenericPortlet implements StrutsStatics,
/**
* Service an action from the <tt>event</tt> phase.
*
*
* @see javax.portlet.Portlet#processAction(javax.portlet.ActionRequest,
* javax.portlet.ActionResponse)
*/
public void processAction(ActionRequest request, ActionResponse response)
throws PortletException, IOException {
LOG.debug("Entering processAction");
Dispatcher.setInstance(dispatcherUtils);
resetActionContext();
try {
serviceAction(request, response, getActionMapping(request),
@@ -301,7 +300,7 @@ public class Jsr168Dispatcher extends GenericPortlet implements StrutsStatics,
/**
* Service an action from the <tt>render</tt> phase.
*
*
* @see javax.portlet.Portlet#render(javax.portlet.RenderRequest,
* javax.portlet.RenderResponse)
*/
@@ -333,7 +332,7 @@ public class Jsr168Dispatcher extends GenericPortlet implements StrutsStatics,
/**
* Merges all application and portlet attributes into a single
* <tt>HashMap</tt> to represent the entire <tt>Action</tt> context.
*
*
* @param requestMap a Map of all request attributes.
* @param parameterMap a Map of all request parameters.
* @param sessionMap a Map of all session attributes.
@@ -360,11 +359,12 @@ public class Jsr168Dispatcher extends GenericPortlet implements StrutsStatics,
if (Settings.isSet(StrutsConstants.STRUTS_LOCALE)) {
locale = LocalizedTextUtil.localeFromString(Settings.get(StrutsConstants.STRUTS_LOCALE), request.getLocale());
} else {
locale = request.getLocale();
locale = request.getLocale();
}
extraContext.put(ActionContext.LOCALE, locale);
extraContext.put(StrutsStatics.STRUTS_PORTLET_CONTEXT, getPortletContext());
extraContext.put(ActionContext.DEV_MODE, Boolean.valueOf(Settings.get(StrutsConstants.STRUTS_DEVMODE)));
extraContext.put(REQUEST, request);
extraContext.put(RESPONSE, response);
extraContext.put(PORTLET_CONFIG, portletConfig);
@@ -390,7 +390,7 @@ public class Jsr168Dispatcher extends GenericPortlet implements StrutsStatics,
* context from the given parameters then loads an <tt>ActionProxy</tt>
* from the given action name and namespace. After that, the action is
* executed and output channels throught the response object.
*
*
* @param request the HttpServletRequest object.
* @param response the HttpServletResponse object.
* @param mapping the action mapping.
@@ -407,6 +407,7 @@ public class Jsr168Dispatcher extends GenericPortlet implements StrutsStatics,
Map sessionMap, Map applicationMap, String portletNamespace,
Integer phase) throws PortletException {
LOG.debug("serviceAction");
Dispatcher.setInstance(dispatcherUtils);
HashMap extraContext = createContextMap(requestMap, parameterMap,
sessionMap, applicationMap, request, response,
getPortletConfig(), phase);