Author: hermanns Date: Wed Sep 13 01:43:37 2006 New Revision: 442897 URL: http://svn.apache.org/viewvc?view=rev&rev=442897 Log: Portlet sample application doesn't work o patches applied
Issue Number: WW-1407 Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/dispatcher/DirectRenderFromEventAction.java struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/dispatcher/DirectRenderFromEventAction.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/dispatcher/DirectRenderFromEventAction.java?view=diff&rev=442897&r1=442896&r2=442897 ============================================================================== --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/dispatcher/DirectRenderFromEventAction.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/dispatcher/DirectRenderFromEventAction.java Wed Sep 13 01:43:37 2006 @@ -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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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 @@ /** * 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; } } Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java?view=diff&rev=442897&r1=442896&r2=442897 ============================================================================== --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java Wed Sep 13 01:43:37 2006 @@ -238,7 +238,7 @@ } } - dispatcherUtils = new Dispatcher(null); + dispatcherUtils = new Dispatcher(ServletContextHolderListener.getServletContext()); } /** @@ -279,14 +279,13 @@ /** * 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 @@ /** * Service an action from the <tt>render</tt> phase. - * + * * @see javax.portlet.Portlet#render(javax.portlet.RenderRequest, * javax.portlet.RenderResponse) */ @@ -333,7 +332,7 @@ /** * 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 @@ 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 @@ * 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 @@ 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);