struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jiin-Her Lu" <J...@kcc.usda.gov>
Subject RE: Validation problem
Date Tue, 03 Feb 2004 22:49:27 GMT
This is an interesting thing. Here is the way to avoid Struts calls  validate method on ActionForm

This one Struts framework will NOT call validate method on ActionForm

<html:cancel value="Cancel" />

While this one does 

<html:cancel property="mycancelbutton" value="Cancel" />

The only difference is if you do have property, Struts adds name="your_data". While if you
don't have property set, Struts add name="org.apache.struts.taglib.html.CANCEL". 

Why these make the difference?????



Jiin-Her Lu
(816) 926-2145

>>> bbarnett@scholarinc.com 01/29/04 05:45PM >>>
The Struts Validator provides a mechanism to deal with Cancel buttons. A
flag is set in the onclick method for the cancel button in the jsp page. The
validate methods check this flag and if it is set, they skip validation and
just return true.
 
<html:cancel onclick="bCancel=true;">

If you're not using the Struts Validator, maybe you could try mimicking this
behavior in your validate method ??

Brian Barnett

-----Original Message-----
From: Nathan Pitts [mailto:jpitts@tahc.state.tx.us] 
Sent: Thursday, January 29, 2004 4:16 PM
To: Struts List
Subject: Validation problem

I am wondering how to solve the following problem with a minimal amount 
of recoding, and hope someone can give some input.  I have a form the 
has three html:submit buttons -- Update, Cancel and Delete.   I am 
using a LookupDispatchAction and an ActionForm with the validation in 
the validate() method.  Under normal conditions everything works 
fine......But when a user clicks Update with invalid data on the form, 
the validate method catches the bad data and returns the proper error 
message.  If the user then decides to click Cancel (without changing 
the invalid data), the validate() method is still called and the user 
is returned the same error.


One thing that I might be able to do is to somehow find out what button 
was clicked in the validate() method...??  How would I do that, I 
wonder...



thanks in advance,
-nathan


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org 
For additional commands, e-mail: struts-user-help@jakarta.apache.org 

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org 
For additional commands, e-mail: struts-user-help@jakarta.apache.org 



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message