I haven't used the Scope interceptor, so I may not be 100% correct, but the following answers are based on my interpretation of the documentation:

j alex wrote:
Hi,

I need help regarding correct usage of Scope interceptor
(http://struts.apache.org/2.0.9/docs/scope-interceptor.html)

Before going into details i had couple of qns :

#1. Is this usable we have multiple actions sharing the same model
object ? - i.e each page of the app posts to a different Action . All
of these Actions extend from a BaseAction in which we've the get() and
set() for the model.

Yes, provided each action is configured with a scope interceptor with the 'key' parameter set to the same value.

Assumptions (please correct me if i'm wrong here) :

#2. If yes to #1, i guess we **must** provide a "key" under which to
save the object

Yes.

#3. The Action class need not implement any special interfaces/extend
any classes -- right now, it extends ActionSupport.

Correct.

The struts.xml is as follows :


<action name="page1" class="com.mysite.Action1" method="input">
        <interceptor-ref name="defaultStack">
           <param name="validation.validateAnnotatedMethodOnly">true</param>
          <param name="scope.key">modelObj</param>                        
          <param name="scope.session">modelObj</param>                    
                <param name="scope.autoCreateSession">true</param>              
          
          </interceptor-ref>              
        <result name="input">page-i1.jsp</result>
        <result>page-o1.jsp</result>
</action>                 

<action name="page2" class="com.mysite.Action2" method="input">
        <interceptor-ref name="defaultStack">
           <param name="validation.validateAnnotatedMethodOnly">true</param>
        <param name="scope.key">modelObj</param>                          
          <param name="scope.session">modelObj</param>                    
                <param name="scope.autoCreateSession">true</param>              
          
          </interceptor-ref>                      
        <result name="input">page-i2.jsp</result>
        <result>page-o2.jsp</result>
</action>


The problem is that the values entered in page-i1.jsp (posting to
page2 Action) are not showing up in page-i2.jsp -- BUT, those were
showing up before the interceptor was added.

Do you have the necessary getModelObj() / setModelObj() methods on Action1 and Action2 respectively? Have you added debug logging to determine if those methods are called at the appropriate points?

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to