Struts Tutorial -- Code ExamplesValidation Framework
Validation Framework provides the functionality to validate the form data. It can be use to validate the data on the client side as well as on the server side.
Follow the below steps to setup Validation Framework in Struts (server side validation ).
Step 1. Add validator plugin into struts-config.xml
Step 3. In the JSP page (EmpForm.jsp)- add <html:errors/>
Step 4. Add Message Resources location in struts-config.xml
Step 5. In the the Resource Bundle. application_resource.properties file //Here you can add localization.
Step 7. In the EmpForm
Step 6. In the validation.xml - The validation.xml file is where you couple the individual Validators defined in the validator-rules.xml to components within your application
Step 6. In the validator-rules.xml - The validator-rules.xml file defines the Validator definitions available for a given application.
Step 5. Add Action mapping and form entry into the stuts-confix.xml and validate="true" is for validation framework to validate the form input.
Now in the browser type http://localhost:8080/testApp/EmpForm.jsp
Don't Enter firstName and lastName in the text box and submit the "Save" BUTTON.
the RequestProcessor checks for the validateattribute in the
First Name is required.
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
SCJP 6.0 Simulator 664+ Questions With Explanations
SCWCD 5.0 Simulator 556+ Questions With Explanations
SCWCD 4.0 Simulator 500+ Questions With Explanations
OCA 10g Simulator 594+ Questions With Explanations
Hiring made easy Harness social networking, employee referrals, Agency portal and Job Portals