Package org.apache.struts2.interceptor
Class ScopedModelDrivenInterceptor
java.lang.Object
org.apache.struts2.interceptor.AbstractInterceptor
org.apache.struts2.interceptor.ScopedModelDrivenInterceptor
- All Implemented Interfaces:
Serializable,ConditionalInterceptor,Interceptor
An interceptor that enables scoped model-driven actions.
This interceptor only activates on actions that implement the ScopedModelDriven interface. If
detected, it will retrieve the model class from the configured scope, then provide it to the Action.
Interceptor parameters:
- className - The model class name. Defaults to the class name of the object returned by the getModel() method.
- name - The key to use when storing or retrieving the instance in a scope. Defaults to the model class name.
- scope - The scope to store and retrieve the model. Defaults to 'request' but can also be 'session'.
Extending the interceptor:
There are no known extension points for this interceptor.Example code:
<-- Basic usage -->
<interceptor name="scopedModelDriven" class="org.apache.struts2.interceptor.ScopedModelDrivenInterceptor" />
<-- Using all available parameters -->
<interceptor name="gangsterForm" class="org.apache.struts2.interceptor.ScopedModelDrivenInterceptor">
<param name="scope">session</param>
<param name="name">gangsterForm</param>
<param name="className">com.opensymphony.example.GangsterForm</param>
</interceptor>
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintercept(ActionInvocation invocation) Override to handle interceptionprotected ObjectresolveModel(ObjectFactory factory, ActionContext actionContext, String modelClassName, String modelScope, String modelName) voidsetClassName(String className) voidvoidsetObjectFactory(ObjectFactory factory) voidMethods inherited from class org.apache.struts2.interceptor.AbstractInterceptor
destroy, init, setDisabled, shouldIntercept
-
Constructor Details
-
ScopedModelDrivenInterceptor
public ScopedModelDrivenInterceptor()
-
-
Method Details
-
setObjectFactory
-
resolveModel
protected Object resolveModel(ObjectFactory factory, ActionContext actionContext, String modelClassName, String modelScope, String modelName) throws Exception - Throws:
Exception
-
intercept
Description copied from class:AbstractInterceptorOverride to handle interception- Specified by:
interceptin interfaceInterceptor- Specified by:
interceptin classAbstractInterceptor- Parameters:
invocation- the action invocation- Returns:
- the return code, either returned from
ActionInvocation.invoke(), or from the interceptor itself. - Throws:
Exception- any system-level error, as defined inAction.execute().
-
setClassName
- Parameters:
className- the className to set
-
setName
- Parameters:
name- the name to set
-
setScope
- Parameters:
scope- the scope to set
-