struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Pratt <thechrispr...@gmail.com>
Subject Re: struts2 disable validation on page load
Date Sun, 07 Oct 2012 05:54:41 GMT
Set the failure result of the processAdd to redirect to the add action.
  (*Chris*)

On Sat, Oct 6, 2012 at 10:30 PM, prashid <pirzada.rashid@gmail.com> wrote:

> Thanks,
>
> if I do processing as <s:form action="processAdd" method="POST">  than the
> URL will change to /processAdd from /add if input error is generated. How I
> stop it from changing URL thus not validate on page load. That's what I
> want?
>
>
>
>
> On Sun, Oct 7, 2012 at 9:19 AM, Chris Pratt [via Struts] <
> ml-node+s1045723n5710744h90@n5.nabble.com> wrote:
>
> > By default Struts 2 validates all methods of the action, except the
> > "input", "back", "cancel", or "browse" methods.  One popular solution to
> > your problem is to prepare the form data in the input() method, then
> > process the form in the execute() method.  To do this you'd need to
> change
> > your setup to:
> >
> > <action name="add" class="com.myapp.actions.StudentAction"
> method="input">
> >   <result name="success" type="redirectAction">list</result>
> >   <result name="input" type="tiles">/student.edit.tiles</result>
> > </action>
> >
> > <action name="processAdd" class="com.myapp.actions.StudentAction">
> >   <result name="success" type="redirectAction">list</result>
> >   <result name="input" type="tiles">/student.edit.tiles</result>
> > </action>
> >
> > Then change your form declaration to:
> >
> > <s:form action="processAdd" method="POST">
> >
> >   (*Chris*)
> >
> > On Sat, Oct 6, 2012 at 9:02 PM, prashid <[hidden email]<
> http://user/SendEmail.jtp?type=node&node=5710744&i=0>>
> > wrote:
> >
> > > I am using xml based validation.
> > >
> > > *Problem:*
> > >
> > > I don't want validation to perform on input form when page loaded first
> > > time
> > > because all the fields are blank for user to fill in. Suppose for
> > register
> > > form to add new student. It should perform once I click the button.
> > >
> > > *Note:* /I want to retain same url even when I do the validation on
> > button
> >
> > > click. New form URL is
> > > http://localhost:8000/Struts2_Spring_Crud/student/add
> > > and if validation fail even than the url should be same./
> > >
> > > *struts.xml*
> > >
> > >
> > >         <action name="add" class="com.myapp.actions.StudentAction"
> > > method="insertOrUpdateStudent">
> > >             <result name="success" type="redirectAction">list</result>
> > >             <result name="input"
> > type="tiles">/student.edit.tiles</result>
> > >         </action>
> > >
> > > *input form*
> > >
> > > <s:fielderror/>
> > >     <s:form action="add" method="POST">
> > >
> > >         <s:label name="name" value="Name *"/>
> > >         <s:textfield name="student.name" value="%{student.name}"/>
> > >         <s:fielderror fieldName="student.name"/>
> > >
> > >         <s:label name="age" value="Age *"/>
> > >         <s:textfield name="student.age" value="%{student.age}"/>
> > >
> > >         <s:submit name="saveForm" value="#title"/>
> > >     </s:form>
> > >
> > >
> > >
> > >
> > >
> > > --
> > > View this message in context:
> > >
> >
> http://struts.1045723.n5.nabble.com/struts2-disable-validation-on-page-load-tp5710743.html
> > > Sent from the Struts - User mailing list archive at Nabble.com.
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [hidden email]<
> http://user/SendEmail.jtp?type=node&node=5710744&i=1>
> > > For additional commands, e-mail: [hidden email]<
> http://user/SendEmail.jtp?type=node&node=5710744&i=2>
> > >
> > >
> >
> >
> > ------------------------------
> >  If you reply to this email, your message will be added to the discussion
> > below:
> >
> >
> http://struts.1045723.n5.nabble.com/struts2-disable-validation-on-page-load-tp5710743p5710744.html
> >  To unsubscribe from struts2 disable validation on page load, click here<
> http://struts.1045723.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5710743&code=cGlyemFkYS5yYXNoaWRAZ21haWwuY29tfDU3MTA3NDN8MTM5MjQ5MDQ5MQ==
> >
> > .
> > 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/struts2-disable-validation-on-page-load-tp5710743p5710745.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message