webwork / docs / wikidocs / Interceptors.html

<html>
    <head>
        <title>WebWork 2 : Interceptors</title>
	    <link rel="stylesheet" href="styles/site.css" type="text/css" />
        <META http-equiv="Content-Type" content="text/html; charset=UTF-8">	    
    </head>

    <body>
	    <table class="pagecontent" border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#ffffff">
		    <tr>
			    <td valign="top" class="pagebody">
				    <div class="pageheader">
					    <span class="pagetitle">
                            WebWork 2 : Interceptors
                                                    </span>
				    </div>
				    <div class="pagesubheading">
					    This page last changed on Jul 22, 2004 by <font color="#0050B2">plightbo</font>.
				    </div>

				    <p class="paragraph"><h2 style="margin: 4px 0px 4px 0px;" class="heading2"><a name="Interceptors-Overview"> Overview</a></h2>
<br clear="all" />
Interceptors are objects that dynamically intercept Action invocations. They provide the developer with the opportunity to define code that can be executed before and/or after the execution of an action. They also have the ability to prevent an action from executing. Interceptors provide developers a way to encapulate common functionality in a re-usable form that can be applied to one or more Actions. See <a href="http://wiki.opensymphony.com//display/XW/Interceptors" title="Interceptors">XW:Interceptors</a> for further details.  Below describes built in Webwork interceptors.
<br clear="all" />
<h3 class="heading3"><a name="Interceptors-Webwork%26amp%3BXWorkInterceptors"> Webwork &amp; XWork Interceptors</a></h3>
<br clear="all" />
Interceptor classes are also defined using a key-value pair specified in the xwork configuration file.  The names specified below come specified in <a href="webwork-default.xml.html" title="webwork-default.xml">webwork-default.xml</a>.  If you extend the webwork-default package, then you can use the names below.  Otherwise they must be defined in your package with a name-class pair specified in the &lt;interceptors&gt; tag.
<br clear="all" /></p><table class="wikitable">
<tr>
<th>Name</th><th>Description</th>
</tr><tr>
<td>timer</td><td>Outputs how long the action (including nested interceptors and view) takes to execute</td>
</tr><tr>
<td>logger</td><td>Outputs the name of the action</td>
</tr><tr>
<td>chain</td><td>Makes the previous action&#039;s properties available to the current action. Commonly used together with &lt;result type=&quot;chain&quot;&gt; (in the previous action.)</td>
</tr><tr>
<td>static-params</td><td>Sets the xwork.xml defined parameters onto the action.  These are the &lt;param&gt; tags that are direct children of the &lt;action&gt; tag.</td>
</tr><tr>
<td>params</td><td>Sets the request parameters onto the action.</td>
</tr><tr>
<td>model-driven</td><td>If the action implements ModelDriven, pushes the getModel() result onto the valuestack.</td>
</tr><tr>
<td>component</td><td>Enables and makes the components available to the Actions. Refer to components.xml</td>
</tr><tr>
<td>token</td><td>Checks for valid token presence in action, prevents duplicate form submission </td>
</tr><tr>
<td>token-session</td><td>Same as above, but storing the submitted data in session when handed an invalid token</td>
</tr><tr>
<td>validation</td><td>Performs validation using the validators defined in &#123;Action&#125;-validation.xml</td>
</tr><tr>
<td>workflow</td><td>Calls the validate method in your action class.  If action errors created then it returns the INPUT view.</td>
</tr><tr>
<td>servlet-config</td><td>Give access to HttpServletRequest and HttpServletResponse (think twice before using this since this ties you to the Servlet api)</td>
</tr><tr>
<td>prepare</td><td>If the action implements Preparable, calls its prepare() method.</td>
</tr><tr>
<td>conversionError </td><td> adds conversion errors from the ActionContext to the Action&#039;s field errors </td>
</tr><tr>
<td>fileUpload</td><td>an interceptor that adds easy access to file upload support; read the javadocs for more info</td>
</tr><tr>
<td>execAndWait</td><td>an interceptor that executes the action in the background and then sends the user off to an intermediate waiting page; read the javadocs for more info</td>
</tr>
</table><br/>
For more information about the chain interceptor, see <a href="Chaining Interceptor.html" title="Chaining Interceptor">WW:Chaining Interceptor</a>.

				    
                    			    </td>
		    </tr>
	    </table>
	    <table border="0" cellpadding="0" cellspacing="0" width="100%">
			<tr>
				<td height="12" background="border/border_bottom.gif"><img src="border/spacer.gif" width="1" height="1" border="0"/></td>
			</tr>
		    <tr>
			    <td align="center"><font color="grey">Document generated by Confluence on Oct 18, 2004 00:08</font></td>
		    </tr>
	    </table>
    </body>
</html>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.