struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sriram <>
Subject RE: What should be in validate() method when using struts validat or package
Date Thu, 10 Jul 2003 06:34:52 GMT
Can you please explain how to use validator for client side validations? Any sample code on
the web (links would be helpful).

-----Original Message-----
From: Nagendra Kumar O V S [] 
Sent: Thursday, July 10, 2003 11:59 AM
Subject: Re: What should be in validate() method when using struts validator package

struts validator provides both client side as well as server side validations.
if u want to use the serverside validations , u have to extend the validatorForm instead of
ActionForm and remove the validate() method all together.
but, in my application, i am using validator for client side validations and on the server
side i still use plain vanilla Action forms and validation method (for validations) for my
own business requirements.
so its a matter of choice.
-------Original Message-------
From: Struts Users Mailing  <> List
Date: Thursday, July 10, 2003 11:42:11 AM
To: 'Struts Users Mailing  <> List'
Subject: What should be in validate() method when using struts validator package
What should be in validate() method when we use Struts Validator package?
Should it be an empty method?

My current validate() method (without using Struts Validator) is as follows:(What should it
be if I implement validations in validator-rules.xml and validations.xml)? Pl. suggest.

public ActionErrors validate(ActionMapping mapping,
javax.servlet.http.HttpServletRequest request) {
// maintenance forms do new, update and delete, but also searches and create new for
// fkey resolvers. Only new and update actually need validation.
if (!lrAction_.equals("New") && !lrAction_.equals("Update")) return null;

ActionErrors errs = new ActionErrors();
SupportValues support = new SupportValues();

try {
} catch (IllegalArgumentException ex) {
errs.add(FLD_CONTACT_NAME,new ActionError("supportviewform.error_contact_name",ex.getMessage()));
try {
} catch (IllegalArgumentException ex) {
errs.add(FLD_CONTACT_DETAIL,new ActionError("supportviewform.error_contact_detail",ex.getMessage()));
try {
} catch (IllegalArgumentException ex) {
errs.add(FLD_PHONE_NO,new ActionError("supportviewform.error_phone_no",ex.getMessage()));
try {
} catch (IllegalArgumentException ex) {
errs.add(FLD_EMAIL_ADDR,new ActionError("supportviewform.error_email_addr",ex.getMessage()));
try {
} catch (IllegalArgumentException ex) {
errs.add(FLD_SUBJECT,new ActionError("supportviewform.error_subject",ex.getMessage()));
try {
} catch (IllegalArgumentException ex) {
errs.add(FLD_MESSAGE,new ActionError("supportviewform.error_message",ex.getMessage()));
if (errs.empty()) return null;

// preserve selected values in the form, so on error don't lose them all.

return errs;
} // end of validate

 <>   IncrediMail - Email has
finally evolved -  <> Click

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