copy event parameters to render parameters in case of an action exception as well (SPR-7495)
This commit is contained in:
parent
3eda5144ae
commit
ba946c08dd
|
|
@ -38,6 +38,7 @@ import javax.portlet.RenderRequest;
|
||||||
import javax.portlet.RenderResponse;
|
import javax.portlet.RenderResponse;
|
||||||
import javax.portlet.ResourceRequest;
|
import javax.portlet.ResourceRequest;
|
||||||
import javax.portlet.ResourceResponse;
|
import javax.portlet.ResourceResponse;
|
||||||
|
import javax.portlet.StateAwareResponse;
|
||||||
import javax.portlet.UnavailableException;
|
import javax.portlet.UnavailableException;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
@ -648,17 +649,7 @@ public class DispatcherPortlet extends FrameworkPortlet {
|
||||||
triggerAfterActionCompletion(mappedHandler, interceptorIndex, processedRequest, response, ex);
|
triggerAfterActionCompletion(mappedHandler, interceptorIndex, processedRequest, response, ex);
|
||||||
// Forward the exception to the render phase to be displayed.
|
// Forward the exception to the render phase to be displayed.
|
||||||
try {
|
try {
|
||||||
// Copy all parameters unless overridden in the action handler.
|
exposeActionException(request, response, ex);
|
||||||
Enumeration<String> paramNames = request.getParameterNames();
|
|
||||||
while (paramNames.hasMoreElements()) {
|
|
||||||
String paramName = paramNames.nextElement();
|
|
||||||
String[] paramValues = request.getParameterValues(paramName);
|
|
||||||
if (paramValues != null && !response.getRenderParameterMap().containsKey(paramName)) {
|
|
||||||
response.setRenderParameter(paramName, paramValues);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
response.setRenderParameter(ACTION_EXCEPTION_RENDER_PARAMETER, Boolean.TRUE.toString());
|
|
||||||
request.getPortletSession().setAttribute(ACTION_EXCEPTION_SESSION_ATTRIBUTE, ex);
|
|
||||||
logger.debug("Caught exception during action phase - forwarding to render phase", ex);
|
logger.debug("Caught exception during action phase - forwarding to render phase", ex);
|
||||||
}
|
}
|
||||||
catch (IllegalStateException ex2) {
|
catch (IllegalStateException ex2) {
|
||||||
|
|
@ -931,8 +922,7 @@ public class DispatcherPortlet extends FrameworkPortlet {
|
||||||
triggerAfterEventCompletion(mappedHandler, interceptorIndex, request, response, ex);
|
triggerAfterEventCompletion(mappedHandler, interceptorIndex, request, response, ex);
|
||||||
// Forward the exception to the render phase to be displayed.
|
// Forward the exception to the render phase to be displayed.
|
||||||
try {
|
try {
|
||||||
response.setRenderParameter(ACTION_EXCEPTION_RENDER_PARAMETER, Boolean.TRUE.toString());
|
exposeActionException(request, response, ex);
|
||||||
request.getPortletSession().setAttribute(ACTION_EXCEPTION_SESSION_ATTRIBUTE, ex);
|
|
||||||
logger.debug("Caught exception during event phase - forwarding to render phase", ex);
|
logger.debug("Caught exception during event phase - forwarding to render phase", ex);
|
||||||
}
|
}
|
||||||
catch (IllegalStateException ex2) {
|
catch (IllegalStateException ex2) {
|
||||||
|
|
@ -1027,6 +1017,26 @@ public class DispatcherPortlet extends FrameworkPortlet {
|
||||||
"]: Does your handler implement a supported interface like Controller?");
|
"]: Does your handler implement a supported interface like Controller?");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expose the given action exception to the given response.
|
||||||
|
* @param request current portlet request
|
||||||
|
* @param response current portlet response
|
||||||
|
* @param ex the action exception (may also come from an event phase)
|
||||||
|
*/
|
||||||
|
protected void exposeActionException(PortletRequest request, StateAwareResponse response, Exception ex) {
|
||||||
|
// Copy all parameters unless overridden in the action handler.
|
||||||
|
Enumeration<String> paramNames = request.getParameterNames();
|
||||||
|
while (paramNames.hasMoreElements()) {
|
||||||
|
String paramName = paramNames.nextElement();
|
||||||
|
String[] paramValues = request.getParameterValues(paramName);
|
||||||
|
if (paramValues != null && !response.getRenderParameterMap().containsKey(paramName)) {
|
||||||
|
response.setRenderParameter(paramName, paramValues);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
response.setRenderParameter(ACTION_EXCEPTION_RENDER_PARAMETER, Boolean.TRUE.toString());
|
||||||
|
request.getPortletSession().setAttribute(ACTION_EXCEPTION_SESSION_ATTRIBUTE, ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render the given ModelAndView. This is the last stage in handling a request.
|
* Render the given ModelAndView. This is the last stage in handling a request.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue