public class ParameterMappingInterceptor extends HandlerInterceptorAdapter
ActionRequest
to the
RenderRequest
.
This can be useful when using ParameterHandlerMapping
or PortletModeParameterHandlerMapping
.
It will ensure that the parameter that was used to map the ActionRequest
to a handler will be forwarded to the RenderRequest
so that it will also be
mapped the same way.
When using this Interceptor, you can still change the value of the mapping parameter in your handler in order to change where the render request will get mapped.
Be aware that this Interceptor does call ActionResponse.setRenderParameter
,
which means that you will not be able to call ActionResponse.sendRedirect
in
your handler. If you may need to issue a redirect, then you should avoid this Interceptor
and either write a different one that does this in a different way, or manually forward
the parameter from within your handler(s).
Thanks to Rainer Schmitz for suggesting this mapping strategy!
ParameterHandlerMapping
,
PortletModeParameterHandlerMapping
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_PARAMETER_NAME
Request parameter name to use for mapping to handlers
|
private java.lang.String |
parameterName |
Constructor and Description |
---|
ParameterMappingInterceptor() |
Modifier and Type | Method and Description |
---|---|
boolean |
preHandleAction(ActionRequest request,
ActionResponse response,
java.lang.Object handler)
If request is an
ActionRequest ,
get handler mapping parameter and add it to the ActionResponse. |
void |
setParameterName(java.lang.String parameterName)
Set the name of the parameter used for mapping.
|
afterActionCompletion, afterCompletion, afterEventCompletion, afterRenderCompletion, afterResourceCompletion, postHandleRender, postHandleResource, preHandle, preHandleEvent, preHandleRender, preHandleResource
public static final java.lang.String DEFAULT_PARAMETER_NAME
private java.lang.String parameterName
public void setParameterName(java.lang.String parameterName)
public boolean preHandleAction(ActionRequest request, ActionResponse response, java.lang.Object handler)
ActionRequest
,
get handler mapping parameter and add it to the ActionResponse.preHandleAction
in interface HandlerInterceptor
preHandleAction
in class HandlerInterceptorAdapter
request
- current portlet action requestresponse
- current portlet action responsehandler
- chosen handler to execute, for type and/or instance evaluationtrue
if the execution chain should proceed with the
next interceptor or the handler itself. Else, DispatcherPortlet
assumes that this interceptor has already dealt with the response itself