You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by j alex <st...@gmail.com> on 2007/08/16 22:11:30 UTC
Help with scope interceptor
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.
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
#3. The Action class need not implement any special interfaces/extend
any classes -- right now, it extends ActionSupport.
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.
It'll be great if someone can help me out with this, since this is a
very basic requirement for the app i'm developing
Thanks,
Joseph
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Help with scope interceptor
Posted by j alex <st...@gmail.com>.
Thanks Laurie for your observations..I'm having the "key" attribute in
struts xml and also setting "start" to true for the first Action ;
doing this puts the object in session, but updates to it made on the
subsequent pages are not being reflected ; ie when we print it out -
the value from session is obtained, not the one which was submitted in
the previous request.
-Josph
On 8/18/07, Laurie Harper <la...@holoweb.net> wrote:
> 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: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Help with scope interceptor
Posted by Laurie Harper <la...@holoweb.net>.
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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org