org.apache.beehive.netui.pageflow.interceptor
Interface ActionInterceptor


public interface ActionInterceptor

Interface for page flow action interceptors. These are configured in /WEB-INF/netui-config.xml like this:

    <netui-config xmlns="http://beehive.apache.org/netui/2004/server/config">
        ...
    
        <pageflow-action-interceptors>
            <global>
                <before-action>
                    <action-interceptor>
                        <interceptor-class>test.BeforeActionInterceptor1</interceptor-class>
                    </action-interceptor>
                    <action-interceptor>
                        <interceptor-class>test.BeforeActionInterceptor2</interceptor-class>
                    </action-interceptor>
                    ...
                </before-action>
                <after-action>
                    <action-interceptor>
                        <interceptor-class>test.AfterActionInterceptor1</interceptor-class>
                    </action-interceptor>
                    <action-interceptor>
                        <interceptor-class>test.AfterActionInterceptor2</interceptor-class>
                    </action-interceptor>
                </after-action>
            </global>
        </pageflow-action-interceptors>
 
        ...
    </netui-config>

 
Note that a registered ActionInterceptor is created and cached as a single instance per ServletContext. It should not hold any per-request or per-session state.


Method Summary
 InterceptorForward doIntercept(HttpServletRequest request, HttpServletResponse response, PageFlowController pageFlow, InterceptorForward originalForward, String actionName)
          Called either before or after (depending on registration; see ActionInterceptor) an action is raised on a page flow.
 InterceptorForward doPostIntercept(HttpServletRequest request, HttpServletResponse response, PageFlowController pageFlow, InterceptorForward originalForward, String returningActionName)
          Called when returning to the original page flow after an action interceptor had shown a nested page flow.
 void init(ActionInterceptorConfig config, ServletContext servletContext)
          Called when this interceptor is being initialized.
 

Method Detail

init

void init(ActionInterceptorConfig config,
          ServletContext servletContext)
Called when this interceptor is being initialized.

Parameters:
config - the configuration object associated with this interceptor.
servletContext - the ServletContext for the current web application.

doIntercept

InterceptorForward doIntercept(HttpServletRequest request,
                               HttpServletResponse response,
                               PageFlowController pageFlow,
                               InterceptorForward originalForward,
                               String actionName)
                               throws Exception
Called either before or after (depending on registration; see ActionInterceptor) an action is raised on a page flow.

Parameters:
request - the current HttpServletRequest.
response - the current HttpServletResponse.
pageFlow - the page flow on which the action is being raised.
originalForward - a wrapper for the original URI from the action that was intercepted. This value will be null if the interceptor was run before the action, or if the action itself returned null.
actionName - the name of the action being raised.
Returns:
an InterceptorForward that changes the destination URI, or null to allow flow to the intended URI. If the returned InterceptorForward points to a nested page flow, then doPostIntercept(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.beehive.netui.pageflow.PageFlowController, org.apache.beehive.netui.pageflow.interceptor.InterceptorForward, java.lang.String) will be called before the nested page flow returns to the original page flow.
Throws:
Exception

doPostIntercept

InterceptorForward doPostIntercept(HttpServletRequest request,
                                   HttpServletResponse response,
                                   PageFlowController pageFlow,
                                   InterceptorForward originalForward,
                                   String returningActionName)
                                   throws Exception
Called when returning to the original page flow after an action interceptor had shown a nested page flow.

Parameters:
request - the current HttpServletRequest.
response - the current HttpServletResponse.
pageFlow - the page flow to which control is being returned.
originalForward - the forward in the original page flow that was intercepted (through #doIntercept) to transfer control to the nested page flow. This object may be returned, in which case the original page flow navigates to the same URI it intended to show before interception occurred.
returningActionName - the action returned by the nested page flow. If null is returned from this method, then that action will be raised on the original page flow.
Returns:
an InterceptorForward that changes the destination URI when returning to the original page flow; or null if the original page flow should handle the nested return normally.
Throws:
Exception