You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by jpiser <jp...@averoinc.com> on 2008/02/15 16:03:20 UTC
Struts 2 client side validation and preparable interceptor?
I have a couple of questions regarding the preparable interceptor:
1. By implementing the preparable interface alone I can have my prepare()
method called before my action. Great, no problem.
But If I want to utilize multiple prepare methods, e.g. prepareInput(),
prepareCreate(), etc.. that does not work unless I add interceptors to my
action like this:
<action name="userMgmt_*" method="{1}" class="pages.userMgmt">
<interceptor-ref name="params"/>
<interceptor-ref name="prepare"/>
<interceptor-ref name="basicStack"/>
<result name="input">/pages/userMgmt/createUser.jsp</result>
<result name="create">/pages/userMgmt/createUser.jsp</result>
<result name="profile">/pages/userMgmt/profile.jsp</result>
</action>
however, at that point none of my client side validation works anymore in my
form in the JSP.
Can anyone explain to me why this is? Am I missing something?
What I am trying to do is have two JSPs, each with similiar forms that have
client side validation, that use the same action bean but call different
action methods and different prepare methods. The reason why I want to use
the same action bean is that all the parameters are the same and they are
both ultimately calling an update method that would be the same, so I do not
need two action beans that would have the same methods.
Thanks for any help you can give!
John
--
View this message in context: http://www.nabble.com/Struts-2-client-side-validation-and-preparable-interceptor--tp15502421p15502421.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Struts 2 client side validation and preparable interceptor?
Posted by Laurie Harper <la...@holoweb.net>.
jpiser wrote:
> I have a couple of questions regarding the preparable interceptor:
> 1. By implementing the preparable interface alone I can have my prepare()
> method called before my action. Great, no problem.
>
> But If I want to utilize multiple prepare methods, e.g. prepareInput(),
> prepareCreate(), etc.. that does not work unless I add interceptors to my
> action like this:
Hmm, I haven't done that but I thought the prepare interceptor could do
this without messing with the interceptor stack. Are you sure you need
to do this?
> <action name="userMgmt_*" method="{1}" class="pages.userMgmt">
> <interceptor-ref name="params"/>
> <interceptor-ref name="prepare"/>
> <interceptor-ref name="basicStack"/>
>
> <result name="input">/pages/userMgmt/createUser.jsp</result>
> <result name="create">/pages/userMgmt/createUser.jsp</result>
> <result name="profile">/pages/userMgmt/profile.jsp</result>
> </action>
>
> however, at that point none of my client side validation works anymore in my
> form in the JSP.
>
> Can anyone explain to me why this is? Am I missing something?
Probably basicStack doesn't include some of the interceptors that need
to be there for client side validation to work. When you specify
interceptors on an action like that, you override the set of
interceptors that would otherwise be applied.
Have you tried replacing the interceptor-ref elements with a single
reference to the paramsPrepareParams stack, or changing the final one to
reference defaultStack instead of basicStack?
L.
> What I am trying to do is have two JSPs, each with similiar forms that have
> client side validation, that use the same action bean but call different
> action methods and different prepare methods. The reason why I want to use
> the same action bean is that all the parameters are the same and they are
> both ultimately calling an update method that would be the same, so I do not
> need two action beans that would have the same methods.
>
> Thanks for any help you can give!
>
> John
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org