• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to ByPass the validation framework

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I am facing one problem with Validation framework in struts.
I have 2 buttons (Back & Save) in my JSP page and i want to validate the page only when user modify the page and press the Save button.
If user didn't modify the page and press back button i don't want to validate the page. Is it any attribute thru which i can bypass the validation.

Thx in advance..
 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Arun,

In the JSP Page,set a property to the two Buttons.
eg)
<html:submit name="Save" value="Save" propery="OperationID">
similarly for the Back Button,
<html:submit name="Back" value="Back" propery="OperationID">


Now in Your Action Form,declare the property Operation Id and generate Getter and Setter for that Property...

I think you are using the Validate method of the Form,
in that you check for the condition whether the operation id is "Back" or "save".

ie)
if(OperationId.equals("Save"))
 
Neela Sathesh
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Arun,

In the JSP Page,set a property to the two Buttons.
eg)
<html:submit name="Save" value="Save" propery="OperationID">
similarly for the Back Button,
<html:submit name="Back" value="Back" propery="OperationID">


Now in Your Action Form,declare the property Operation Id and generate Getter and Setter for that Property...

I think you are using the Validate method of the Form,
in that you check for the condition whether the operation id is "Back" or "save".

ie)
if(OperationId.equals("Save"))
{
//Perform ur Validations


}
else
{
//Don't perform any validations
}
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Arun,

I think u use a property for ur Button,in that case the problem won't occur.

Thanks,
Neela Vinayagam.N
 
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Arun Sri:
Hi All,
I am facing one problem with Validation framework in struts.
I have 2 buttons (Back & Save) in my JSP page and i want to validate the page only when user modify the page and press the Save button.
If user didn't modify the page and press back button i don't want to validate the page. Is it any attribute thru which i can bypass the validation.

Thx in advance..



What you want is for the Back button to be treated like a Cancel button. You do this in Velocity using the $form.cancelName (or $form.getCancelName()). In JSP its a constant in the Struts html taglib.. Here's the Velocity doc.

getCancelName
public java.lang.String getCancelName()Returns the query parameter name under which a cancel button press must be reported if form validation is to be skipped.

This is the value of org.apache.struts.taglib.html.Constants.CANCEL_PROPERTY

Here's an example of its use
reply
    Bookmark Topic Watch Topic
  • New Topic