Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How to create validations?what are struts validation
components?

Answer Posted / tarun

The validation in struts is done by 2 ways. one is
programmatic validation and Declarative validation. I
programmatic validation we override the
validate(ActionMapping am, HttpServletRequest req) method
provided by ActionClass. This method returns the ActionErros.
For Example :

public ActionErrors validate(ActionMapping am,
HttpServletRequest req){
ActionErrors ae = new ActionErrors();
if(username==null ||
username.equals("")){ae.add("unameError", new
ActionMessage("uname.empty"));}

if(password==null || password.equals("")){
ae.add("passError", new ActionMessage("pass.empty"));
}else if(password.length()<5){
ae.add("passError", new ActionMessage("pass.minlength"));
}
return ae;
}
The values of pass.minlength , pass.empty, uname.empty will
be described in the properities file.

And in the case of declarative validation we extend the form
bean class from anyone of these classes DynaValidatorForm,
DynaValidatorActionForm

the first two classes are defined in
org.apache.struts.validator.*;
In this case we need validator.xml and validator-rules.xml
and properties file.

Is This Answer Correct ?    17 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is apache struts vulnerability?

878


Explain struts?

967


What do you mean by the abstract package in struts2, and what is its utilization?

884


How is the mvc design pattern used in struts framework?

910


What are the conditions for actionform to work correctly?

958


How does struts work?

895


State an example of struts configuration file as an action parameter for action servlet.

956


At the point, you should go for struts framework?

880


What is the purpose of action-mappings tag in struct-config.xml?

917


What are the struts2 configuration properties that control file uploading process?

1055


What is the difference between struts and spring? Explain

856


How can we group related actions in one group in Struts?

913


Give an alternative way to protect jsp’s with not much features from direct access.

942


Explain about the process of functioning of the struts program?

976


Which technologies can be used at view layer in struts?

1017