Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Wiki Markup
{snippet:id=description|javadoc=true|url=struts-core:org.apache.struts2.interceptor.ScopeInterceptor}

...

The scope interceptor can be used to pass arbitrary objects from one action ActionA to another other ActionB, provided you have a getter in ActionA and and a similar setter in actionB. Also, you should use a key parameter to make sure you tell ASF/WW which action gets which objects. This allows you to mix several actions with several scopes, without running the risk of getting wrong objects.

Code Block
xml
xml

    		<action name="scopea" class="com.mevipro.test.action.ScopeActionA">
			<result name="success" type="dispatcher">/jsp/test.jsp</result>
			<interceptor-ref name="basicStack"/>
			<interceptor-ref name="scope">
				<param name="key">funky</param>
        		<param name="session">person</param>
        		<param name="autoCreateSession">true</param>
    		</interceptor-ref>
		</action>
		<action name="scopeb" class="com.mevipro.test.action.ScopeActionB">
			<result name="success" type="dispatcher">/jsp/test.jsp</result>
			<interceptor-ref name="scope">
				<param name="key">funky</param>
        		<param name="session">person</param>
        		<param name="autoCreateSession">true</param>
    		</interceptor-ref>
			<interceptor-ref name="basicStack"/>
		</action>

...