FileDocCategorySizeDatePackage
PortletPreferencesInterceptor.javaAPI DocExample3725Mon Jul 23 13:26:38 BST 2007org.apache.struts2.portlet.interceptor

PortletPreferencesInterceptor

public class PortletPreferencesInterceptor extends com.opensymphony.xwork2.interceptor.AbstractInterceptor implements org.apache.struts2.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:

  • None

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>

see
PortletPreferencesAware

Fields Summary
private static final Log
LOG
Constructors Summary
Methods Summary
public java.lang.Stringintercept(com.opensymphony.xwork2.ActionInvocation invocation)

    
          
        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();