org.apache.struts2.interceptor
类 MessageStoreInterceptor

java.lang.Object
  继承者 com.opensymphony.xwork2.interceptor.AbstractInterceptor
      继承者 org.apache.struts2.interceptor.MessageStoreInterceptor
所有已实现的接口:
com.opensymphony.xwork2.interceptor.Interceptor, Serializable

public class MessageStoreInterceptor
extends com.opensymphony.xwork2.interceptor.AbstractInterceptor

An interceptor to store a ValidationAware action's messages / errors and field errors into HTTP Session, such that it will be retrievable at a later stage. This allows the action's message / errors and field errors to be available longer that just the particular HTTP request. If no session exists, nothing will be stored and can be retrieved later. In other terms, the application is responsible to open the session.

In the 'STORE' mode, the interceptor will store the ValidationAware action's message / errors and field errors into HTTP session.

In the 'RETRIEVE' mode, the interceptor will retrieve the stored action's message / errors and field errors and put them back into the ValidationAware action.

In the 'AUTOMATIC' mode, the interceptor will always retrieve the stored action's message / errors and field errors and put them back into the ValidationAware action, and after Action execution, if the Result is an instance of ServletRedirectResult, the action's message / errors and field errors into automatically be stored in the HTTP session..

The interceptor does nothing in the 'NONE' mode, which is the default.

The operation mode could be switched using :-

1] Setting the iterceptor parameter eg.

   <action name="submitApplication" ...>
      <interceptor-ref name="store">
         <param name="operationMode">STORE</param>
      </interceptor-ref>
      <interceptor-ref name="defaultStack" />
      ....
   </action>
 
2] Through request parameter (allowRequestParameterSwitch must be 'true' which is the default)
   // the request will have the operation mode in 'STORE'
   http://localhost:8080/context/submitApplication.action?operationMode=STORE
 

The following method could be overriden :-

 

 <action name="submitApplication" ....>
    <interceptor-ref name="store">
      <param name="operationMode">STORE</param>
    </interceptor-ref>
    <interceptor-ref name="defaultStack" />
    <result name="input" type="redirect">applicationFailed.action</result>
    <result type="dispatcher">applicationSuccess.jsp</result>
 </action>

 <action name="applicationFailed" ....>
    <interceptor-ref name="store">
       <param name="operationMode">RETRIEVE</param>
    </interceptor-ref>
    <result>applicationFailed.jsp</result>
 </action>

 
 
With the example above, 'submitApplication.action' will have the action messages / errors / field errors stored in the HTTP Session. Later when needed, (in this case, when 'applicationFailed.action' is fired, it will get the action messages / errors / field errors stored in the HTTP Session and put them back into the action.

版本:
$Date$ $Id$
另请参见:
序列化表格

字段摘要
static String actionErrorsSessionKey
           
static String actionMessagesSessionKey
           
static String AUTOMATIC_MODE
           
static String fieldErrorsSessionKey
           
static String NONE
           
static String RETRIEVE_MODE
           
static String STORE_MODE
           
 
构造方法摘要
MessageStoreInterceptor()
           
 
方法摘要
 boolean getAllowRequestParameterSwitch()
           
 String getOperationModel()
           
 String getRequestParameterSwitch()
           
 String intercept(com.opensymphony.xwork2.ActionInvocation invocation)
           
 void setAllowRequestParameterSwitch(boolean allowRequestParameterSwitch)
           
 void setOperationMode(String operationMode)
           
 void setRequestParameterSwitch(String requestParameterSwitch)
           
 
从类 com.opensymphony.xwork2.interceptor.AbstractInterceptor 继承的方法
destroy, init
 
从类 java.lang.Object 继承的方法
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

AUTOMATIC_MODE

public static final String AUTOMATIC_MODE
另请参见:
常量字段值

STORE_MODE

public static final String STORE_MODE
另请参见:
常量字段值

RETRIEVE_MODE

public static final String RETRIEVE_MODE
另请参见:
常量字段值

NONE

public static final String NONE
另请参见:
常量字段值

fieldErrorsSessionKey

public static final String fieldErrorsSessionKey
另请参见:
常量字段值

actionErrorsSessionKey

public static final String actionErrorsSessionKey
另请参见:
常量字段值

actionMessagesSessionKey

public static final String actionMessagesSessionKey
另请参见:
常量字段值
构造方法详细信息

MessageStoreInterceptor

public MessageStoreInterceptor()
方法详细信息

setAllowRequestParameterSwitch

public void setAllowRequestParameterSwitch(boolean allowRequestParameterSwitch)

getAllowRequestParameterSwitch

public boolean getAllowRequestParameterSwitch()

setRequestParameterSwitch

public void setRequestParameterSwitch(String requestParameterSwitch)

getRequestParameterSwitch

public String getRequestParameterSwitch()

setOperationMode

public void setOperationMode(String operationMode)

getOperationModel

public String getOperationModel()

intercept

public String intercept(com.opensymphony.xwork2.ActionInvocation invocation)
                 throws Exception
指定者:
接口 com.opensymphony.xwork2.interceptor.Interceptor 中的 intercept
指定者:
com.opensymphony.xwork2.interceptor.AbstractInterceptor 中的 intercept
抛出:
Exception