1600 PMP mock questions 1400 CAPM mock questions 800 SCJP 6 mock questions 600 OCAJP 7 mock questions 590 OCPJP 7 mock questions 556 SCWCD 5 mock questions 500 OCEJWCD 6 mock questions pdfDownload (java,struts, hibernet etc)

Struts Tutorials

Q.How does validator framework work in struts ?

There are two configuration files used.
One if called validator-rules.xml and the other is validation.xml.
This is example of server side validation :

validator-rules.xml :

The validator-rules.xml file defines the Validator definitions available for a given application.
The validator-rules.xml file acts as a template, defining all of the possible Validators that are available to an application.
Example validator-rules.xml File :


validation.xml File :
The validation.xml file is where you couple the individual Validators defined in the validator-rules.xml to components within your application.
validation.xml File

<form name="empForm">
<arg0 key="label.firstName"/>

<arg0 key="label.lastName"/>

In the empForm firstName and lastName are the required filed.
So in the above configuration you can see we add for both firstName and lastName.
You can see depends="required" - "required" property is defind in validator-rules.xml.

In the resource bundle : application_resource.propertis file
label.firstName=First Name
label.lastName=Last Name

#Error messages used by the Validator
errors.required={0} is required.

Based on the validation.xml File configuration .
Error in jsp will be :
First Name is required.
Last Name is required.

{0} will be filled by (First Name or Last Name) because validation.xml above configuration you have defind <arg0 key="label.firstName"/>.

Reviews and Comments

PMP, CAPM, PMI is a registered certification mark of the Project Management Institute, Inc

Copyright © www.techfaq360.com 2019

About US | Contact US | Privacy Policy | Terms and Conditions  | Website disclaimer  | Cancellation and Refund Policy  | Shipping & Delivery Policy