com.opensymphony.xwork.interceptor
Class PrepareInterceptor

java.lang.Object
  extended by com.opensymphony.xwork.interceptor.AroundInterceptor
      extended by com.opensymphony.xwork.interceptor.PrepareInterceptor
All Implemented Interfaces:
Interceptor, Serializable

public class PrepareInterceptor
extends AroundInterceptor

This interceptor calls prepare() on actions which implement Preparable. This interceptor is very useful for any situation where you need to ensure some logic runs before the actual execute method runs.

A typical use of this is to run some logic to load an object from the database so that when parameters are set they can be set on this object. For example, suppose you have a User object with two properties: id and name. Provided that the params interceptor is called twice (once before and once after this interceptor), you can load the User object using the id property, and then when the second params interceptor is called the parameter user.name will be set, as desired, on the actual object loaded from the database. See the example for more info.

Interceptor parameters:

Extending the interceptor:

There are no known extension points to this interceptor.

Example code:

 
 <!-- Calls the params interceptor twice, allowing you to
      pre-load data for the second time parameters are set -->
 <action name="someAction" class="com.examples.SomeAction">
     <interceptor-ref name="params"/>
     <interceptor-ref name="prepare"/>
     <interceptor-ref name="basicStack"/>
     <result name="success">good_result.ftl</result>
 </action>
 
 
Date: Nov 5, 2003 2:33:11 AM

Author:
Jason Carreira, Philip Luppens, tm_jee
See Also:
Preparable, Serialized Form

Field Summary
 
Fields inherited from class com.opensymphony.xwork.interceptor.AroundInterceptor
log
 
Constructor Summary
PrepareInterceptor()
           
 
Method Summary
protected  void after(ActionInvocation dispatcher, String result)
          Called after the invocation has been executed.
protected  void before(ActionInvocation invocation)
          Called before the invocation has been executed.
 void setAlwaysInvokePrepare(String alwaysInvokePrepare)
           
 
Methods inherited from class com.opensymphony.xwork.interceptor.AroundInterceptor
destroy, init, intercept
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrepareInterceptor

public PrepareInterceptor()
Method Detail

setAlwaysInvokePrepare

public void setAlwaysInvokePrepare(String alwaysInvokePrepare)

after

protected void after(ActionInvocation dispatcher,
                     String result)
              throws Exception
Description copied from class: AroundInterceptor
Called after the invocation has been executed.

Specified by:
after in class AroundInterceptor
result - the result value returned by the invocation
Throws:
Exception

before

protected void before(ActionInvocation invocation)
               throws Exception
Description copied from class: AroundInterceptor
Called before the invocation has been executed.

Specified by:
before in class AroundInterceptor
Throws:
Exception

XWork Project Page