struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Givler, Eric" <egiv...@state.pa.us>
Subject RE: Conditional Validation
Date Mon, 31 Jul 2006 16:13:38 GMT
Can you override the validate() method in your form that extends ValidatorForm, and then inside
that do something like this?
 
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    ActionErrors errors = null;
    if ( request.getParameter("closeButton") == null ) {
       // close button not pressed - so validate
       errors= super.validate(mapping,request);
    }
    return errors;
} // validate()
   

	-----Original Message----- 
	From: Caroline Jen [mailto:jiapei_jen@yahoo.com] 
	Sent: Sun 7/30/2006 12:44 AM 
	To: user@struts.apache.org 
	Cc: 
	Subject: Conditional Validation
	
	

	I am using the Struts validation.xml to check if
	clients leave any of the required text fields in the
	form blank.
	
	I prepared two action mappings for this web page.  The
	'validate'attribute is set to "false" for the first
	action mapping because when I have the web page
	displayed in the browserat the first time, I do not
	want to perform the validation check.
	
	The 'validate' attribute is set to "true" for the
	second action mapping so that validation is performed
	if clients click on the "Submit" button.
	
	So far so good.
	
	But, there is also a "Close" button in the web page.
	If the 'Close' button is clicked, the previous web
	page is supposed to be displayed.
	
	Clients are not expected to fill out the form should
	they choose to click on the 'Close' button.  What
	should I do if I do not want to perform the validation
	check if the 'Close' button is clicked? 
	
	
	
	__________________________________________________
	Do You Yahoo!?
	Tired of spam?  Yahoo! Mail has the best spam protection around
	http://mail.yahoo.com
	
	---------------------------------------------------------------------
	To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
	For additional commands, e-mail: user-help@struts.apache.org
	
	

Mime
View raw message