org.apache.struts2.portlet.interceptor
public class: PortletPreferencesInterceptor [javadoc |
source]
java.lang.Object
com.opensymphony.xwork2.interceptor.AbstractInterceptor
org.apache.struts2.portlet.interceptor.PortletPreferencesInterceptor
All Implemented Interfaces:
StrutsStatics
An interceptor which provides an implementation of PortletPreferences if the Action implements
PortletPreferencesAware.
If running in a servlet environment, a testing implementation of PortletPreferences will be
created and provided, but it should not be used in a production environment.
Interceptor parameters:
Extending the interceptor:
There are no known extension points for this interceptor.
Example code:
<action name="someAction" class="com.examples.SomeAction">
<interceptor-ref name="portlet-preferences"/>
<interceptor-ref name="basicStack"/>
<result name="success">good_result.ftl</result>
</action>
| Method from org.apache.struts2.portlet.interceptor.PortletPreferencesInterceptor Summary: |
|---|
|
intercept |
| Methods from java.lang.Object: |
|---|
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method from org.apache.struts2.portlet.interceptor.PortletPreferencesInterceptor Detail: |
public String intercept(ActionInvocation invocation) throws Exception {
final Object action = invocation.getAction();
final ActionContext context = invocation.getInvocationContext();
if (action instanceof PortletPreferencesAware) {
PortletRequest request = PortletActionContext.getRequest();
PortletPreferencesAware awareAction = (PortletPreferencesAware) action;
// Check if running in a servlet environment
if (request == null) {
LOG.warn("This portlet preferences implementation should only be used during development");
awareAction.setPortletPreferences(new ServletPortletPreferences(ActionContext.getContext().getSession()));
} else {
awareAction.setPortletPreferences(request.getPreferences());
}
}
return invocation.invoke();
}
|