You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by cyanoboy <ma...@libero.it> on 2012/12/21 11:27:39 UTC
Store Interceptor not working with field error (using Hibernate
validation)
I have a Jsp with some textfields, these are validate using Hibernate
validation annotation (@Valid or @NotNull in the action) except one (input
image file) that is validate with default Struts2 validation (using
ActionName-validation.xml). I want to redirect to another action when the
submitted form is invalid (when textfields are null), and I want to store
fields error.
I tried with this:
<interceptors>
<interceptor name="SessionCheckInterceptor"
class="util.SessionCheckInterceptor"/>
<interceptor-stack name="mySessionValidationStack">
<interceptor-ref name="defaultStackHibernate" />
<interceptor-ref name="SessionCheckInterceptor" />
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="mySessionValidationStack"/>
<action name="insert" class="actions.InsertAction" >
<interceptor-ref name="mySessionValidationStack">
image/png
</interceptor-ref>
<interceptor-ref name="store">
STORE
</interceptor-ref>
<interceptor-ref name="defaultStack" />
<result name="success" type="tiles" >baseLayout</result>
<result name="error" type="redirectAction" >
showinsertform
</result>
<result name="input" type="redirectAction" >
showinsertform
</result>
</action>
<action name="showinsertform" class="actions.ShowInsertFormAction" >
<interceptor-ref name="mySessionValidationStack" />
<interceptor-ref name="store">
RETRIEVE
</interceptor-ref>
<result name="success" type="tiles" >insert</result>
<result name="error" type="tiles" >baseLayout</result>
</action>
But when I sumbit the form, the redirect succeed without showing me fields
error messages. Maybe I'm setting wrong the interceptor? Using hibernate I
need to override something? If I try to set manually error messages in the
action (with addActionError), they works! Can it be that hibernate error
fields messages are not stored in the session?
--
View this message in context: http://struts.1045723.n5.nabble.com/Store-Interceptor-not-working-with-field-error-using-Hibernate-validation-tp5711481.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: Store Interceptor not working with field error (using Hibernate validation)
Posted by Lukasz Lenart <lu...@apache.org>.
2012/12/22 cyanoboy <ma...@libero.it>:
> <package name="myStrutsSite" namespace="/" extends="hibernate-default">
>
> <result-types>
> <result-type name="tiles"
> class="org.apache.struts2.views.tiles.TilesResult" />
> </result-types>
>
> <interceptors>
> <interceptor name="SessionCheckInterceptor"
> class="myStrutsSite.util.SessionCheckInterceptor"/>
> <interceptor-stack name="mySessionValidationStack">
> <interceptor-ref name="defaultStackHibernate" />
> <interceptor-ref name="SessionCheckInterceptor" />
> </interceptor-stack>
> </interceptors>
You're using a custom interceptor stack so maybe you setup it in wrong
order - I mean order of interceptors is important :-)
Regards
--
Ćukasz
+ 48 606 323 122 http://www.lenart.org.pl/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Store Interceptor not working with field error (using Hibernate
validation)
Posted by cyanoboy <ma...@libero.it>.
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="true" />
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.custom.i18n.resources"
value="struts-messages" />
<package name="myStrutsSite" namespace="/" extends="hibernate-default">
<result-types>
<result-type name="tiles"
class="org.apache.struts2.views.tiles.TilesResult" />
</result-types>
<interceptors>
<interceptor name="SessionCheckInterceptor"
class="myStrutsSite.util.SessionCheckInterceptor"/>
<interceptor-stack name="mySessionValidationStack">
<interceptor-ref name="defaultStackHibernate" />
<interceptor-ref name="SessionCheckInterceptor" />
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="mySessionValidationStack"/>
<global-results>
<result name="sessionexpired" type="redirectAction" >
<param name="actionName">index</param>
</result>
</global-results>
<action name="login" class="myStrutsSite.actions.LoginAction" >
<result name="input" type="tiles" >baseLayout</result>
<result name="success" type="tiles" >baseLayout</result>
<result name="error" type="tiles" >baseLayout</result>
</action>
<action name="register"
class="myStrutsSite.actions.RegisterAction" >
<result name="input" type="tiles">registration</result>
<result name="success" type="tiles">baseLayout</result>
<result name="error" type="tiles">registration</result>
</action>
<action name="logout" class="myStrutsSite.actions.LogoutAction" >
<result name="success" type="tiles" >baseLayout</result>
</action>
<action name="index" class="myStrutsSite.actions.HomeAction" >
<interceptor-ref name="defaultStackHibernate" />
<result name="success" type="tiles">baseLayout</result>
</action>
<action name="showinsertform"
class="myStrutsSite.actions.ShowInsertFormAction" >
<interceptor-ref name="mySessionValidationStack" />
<interceptor-ref name="store">
<param name="operationMode">RETRIEVE</param>
</interceptor-ref>
<result name="success" type="tiles" >insert</result>
<result name="error" type="tiles" >baseLayout</result>
</action>
<action name="insert" class="myStrutsSite.actions.InsertAction" >
<interceptor-ref name="mySessionValidationStack">
<param name="fileUpload.allowedTypes">image/png</param>
</interceptor-ref>
<interceptor-ref name="store">
<param name="operationMode">STORE</param>
</interceptor-ref>
<interceptor-ref name="defaultStack" />
<result name="success" type="tiles" >baseLayout</result>
<result name="error" type="redirectAction" >
<param name="actionName">showinsertform</param>
</result>
<result name="input" type="redirectAction" >
<param name="actionName">showinsertform</param>
</result>
</action>
<action name="*" >
<result name="success" type="tiles" >{1}</result>
</action>
</package>
</struts>
Il 22/12/2012 04:53, mohan rao [via Struts] ha scritto:
> Can you share complete struts.xml complete configuration.
>
>
>
> On Fri, Dec 21, 2012 at 10:48 PM, cyanoboy <[hidden email]
> </user/SendEmail.jtp?type=node&node=5711488&i=0>> wrote:
>
> > I copied wrong. The right code is this:
> >
> > <interceptors>
> > <interceptor name="SessionCheckInterceptor"
> > class="util.SessionCheckInterceptor"/>
> > <interceptor-stack name="mySessionValidationStack">
> > <interceptor-ref name="defaultStackHibernate" />
> > <interceptor-ref name="SessionCheckInterceptor" />
> > </interceptor-stack>
> > </interceptors>
> >
> > <default-interceptor-ref name="mySessionValidationStack"/>
> >
> > <action name="insert" class="actions.InsertAction" >
> > <interceptor-ref name="mySessionValidationStack">
> > image/png
> > </interceptor-ref>
> > <interceptor-ref name="store">
> > STORE
> > </interceptor-ref>
> > <interceptor-ref name="defaultStack" />
> > <result name="success" type="tiles" >baseLayout</result>
> > <result name="error" type="redirectAction" >
> > showinsertform
> > </result>
> > <result name="input" type="redirectAction" >
> > showinsertform
> > </result>
> > </action>
> >
> > <action name="showinsertform" class="actions.ShowInsertFormAction" >
> > <interceptor-ref name="mySessionValidationStack" />
> > <interceptor-ref name="store">
> > RETRIEVE
> > </interceptor-ref>
> > <result name="success" type="tiles" >insert</result>
> > <result name="error" type="tiles" >baseLayout</result>
> > </action>
> >
> > So, where is the problem?
> >
> >
> >
> > --
> > View this message in context:
> >
> http://struts.1045723.n5.nabble.com/Store-Interceptor-not-working-with-field-error-using-Hibernate-validation-tp5711481p5711486.html
> > Sent from the Struts - User mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> </user/SendEmail.jtp?type=node&node=5711488&i=1>
> > For additional commands, e-mail: [hidden email]
> </user/SendEmail.jtp?type=node&node=5711488&i=2>
> >
> >
>
>
> ------------------------------------------------------------------------
> If you reply to this email, your message will be added to the
> discussion below:
> http://struts.1045723.n5.nabble.com/Store-Interceptor-not-working-with-field-error-using-Hibernate-validation-tp5711481p5711488.html
>
> To unsubscribe from Store Interceptor not working with field error
> (using Hibernate validation), click here
> <http://struts.1045723.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5711481&code=bWFyY294ODcyMDAyQGxpYmVyby5pdHw1NzExNDgxfC01MDYzOTA3MzM=>.
> NAML
> <http://struts.1045723.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
--
View this message in context: http://struts.1045723.n5.nabble.com/Store-Interceptor-not-working-with-field-error-using-Hibernate-validation-tp5711481p5711489.html
Sent from the Struts - User mailing list archive at Nabble.com.
Re: Store Interceptor not working with field error (using Hibernate validation)
Posted by vEnkaTa mohAna rAo SriperumbUdUru <mo...@gmail.com>.
Can you share complete struts.xml complete configuration.
On Fri, Dec 21, 2012 at 10:48 PM, cyanoboy <ma...@libero.it> wrote:
> I copied wrong. The right code is this:
>
> <interceptors>
> <interceptor name="SessionCheckInterceptor"
> class="util.SessionCheckInterceptor"/>
> <interceptor-stack name="mySessionValidationStack">
> <interceptor-ref name="defaultStackHibernate" />
> <interceptor-ref name="SessionCheckInterceptor" />
> </interceptor-stack>
> </interceptors>
>
> <default-interceptor-ref name="mySessionValidationStack"/>
>
> <action name="insert" class="actions.InsertAction" >
> <interceptor-ref name="mySessionValidationStack">
> image/png
> </interceptor-ref>
> <interceptor-ref name="store">
> STORE
> </interceptor-ref>
> <interceptor-ref name="defaultStack" />
> <result name="success" type="tiles" >baseLayout</result>
> <result name="error" type="redirectAction" >
> showinsertform
> </result>
> <result name="input" type="redirectAction" >
> showinsertform
> </result>
> </action>
>
> <action name="showinsertform" class="actions.ShowInsertFormAction" >
> <interceptor-ref name="mySessionValidationStack" />
> <interceptor-ref name="store">
> RETRIEVE
> </interceptor-ref>
> <result name="success" type="tiles" >insert</result>
> <result name="error" type="tiles" >baseLayout</result>
> </action>
>
> So, where is the problem?
>
>
>
> --
> View this message in context:
> http://struts.1045723.n5.nabble.com/Store-Interceptor-not-working-with-field-error-using-Hibernate-validation-tp5711481p5711486.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: Store Interceptor not working with field error (using Hibernate
validation)
Posted by cyanoboy <ma...@libero.it>.
I copied wrong. The right code is this:
<interceptors>
<interceptor name="SessionCheckInterceptor"
class="util.SessionCheckInterceptor"/>
<interceptor-stack name="mySessionValidationStack">
<interceptor-ref name="defaultStackHibernate" />
<interceptor-ref name="SessionCheckInterceptor" />
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="mySessionValidationStack"/>
<action name="insert" class="actions.InsertAction" >
<interceptor-ref name="mySessionValidationStack">
image/png
</interceptor-ref>
<interceptor-ref name="store">
STORE
</interceptor-ref>
<interceptor-ref name="defaultStack" />
<result name="success" type="tiles" >baseLayout</result>
<result name="error" type="redirectAction" >
showinsertform
</result>
<result name="input" type="redirectAction" >
showinsertform
</result>
</action>
<action name="showinsertform" class="actions.ShowInsertFormAction" >
<interceptor-ref name="mySessionValidationStack" />
<interceptor-ref name="store">
RETRIEVE
</interceptor-ref>
<result name="success" type="tiles" >insert</result>
<result name="error" type="tiles" >baseLayout</result>
</action>
So, where is the problem?
--
View this message in context: http://struts.1045723.n5.nabble.com/Store-Interceptor-not-working-with-field-error-using-Hibernate-validation-tp5711481p5711486.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: Store Interceptor not working with field error (using Hibernate validation)
Posted by vEnkaTa mohAna rAo SriperumbUdUru <mo...@gmail.com>.
<action name="applicationFailed" ....>
<interceptor-ref name="store">
*<param name="operationMode">RETRIEVE</param> <!--
operationMode missed -->*
</interceptor-ref>
<result>applicationFailed.jsp</result></action>
On Fri, Dec 21, 2012 at 3:57 PM, cyanoboy <ma...@libero.it> wrote:
> I have a Jsp with some textfields, these are validate using Hibernate
> validation annotation (@Valid or @NotNull in the action) except one (input
> image file) that is validate with default Struts2 validation (using
> ActionName-validation.xml). I want to redirect to another action when the
> submitted form is invalid (when textfields are null), and I want to store
> fields error.
>
> I tried with this:
>
> <interceptors>
> <interceptor name="SessionCheckInterceptor"
> class="util.SessionCheckInterceptor"/>
> <interceptor-stack name="mySessionValidationStack">
> <interceptor-ref name="defaultStackHibernate" />
> <interceptor-ref name="SessionCheckInterceptor" />
> </interceptor-stack>
> </interceptors>
>
> <default-interceptor-ref name="mySessionValidationStack"/>
>
> <action name="insert" class="actions.InsertAction" >
> <interceptor-ref name="mySessionValidationStack">
> image/png
> </interceptor-ref>
> <interceptor-ref name="store">
> STORE
> </interceptor-ref>
> <interceptor-ref name="defaultStack" />
> <result name="success" type="tiles" >baseLayout</result>
> <result name="error" type="redirectAction" >
> showinsertform
> </result>
> <result name="input" type="redirectAction" >
> showinsertform
> </result>
> </action>
>
> <action name="showinsertform" class="actions.ShowInsertFormAction" >
> <interceptor-ref name="mySessionValidationStack" />
> <interceptor-ref name="store">
> RETRIEVE
> </interceptor-ref>
> <result name="success" type="tiles" >insert</result>
> <result name="error" type="tiles" >baseLayout</result>
> </action>
>
> But when I sumbit the form, the redirect succeed without showing me fields
> error messages. Maybe I'm setting wrong the interceptor? Using hibernate I
> need to override something? If I try to set manually error messages in the
> action (with addActionError), they works! Can it be that hibernate error
> fields messages are not stored in the session?
>
>
>
> --
> View this message in context:
> http://struts.1045723.n5.nabble.com/Store-Interceptor-not-working-with-field-error-using-Hibernate-validation-tp5711481.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
>
>