<><><><><><>
ValidatorForm
|
ValidatorActionForm
|
|
What
|
Class provided by struts framework for validating form fields
|
Class provided by struts framework for validating form fields
|
Why
|
Instead of manually using basic validation using validate() method in
action class, harnesses the rich feature of validation framework( or
descriptive validation) provided by the struts using XML Files(Validation-rule.xml
& validations.xml)
|
Instead of manually using basic validation using validate() method in
action class, harnesses the rich feature of validation framework( or
descriptive validation) provided by the struts using XML Files(Validation-rule.xml
& validations.xml)
|
How
|
By extending the form class
Ex:
Public class MyForm extends ValidatorForm{
properties & getters setters
|
By extending the form class
Ex:
Public class MyForm extends ValidatorActionForm{
properties & getters setters
|
Where
|
In any web application which is implemented using struts
|
In any web application which is implemented using struts
|
Difference
|
It uses ‘form name’ as identifier to invoke validation
|
It uses ‘action name’ as identifier to invoke validation
|
The validations.xml file will be configured as <form-name =”name
of the form mentioned in config file related to particular action”>
Ex
Validations.xml
<formset>
---------------------------
----------------------------
</form-name>
struts-config.xml
<form-beans>
<form-bean name=”myForm”
type=”--------“/>
</form-beans>
<action-mapping>
<action path=”/myFormAction”
name= ”myForm”
type=………
/>
|
The validations.xml file will be configured as <form-name =”action
path mentioned in struts-config.xml”>
Ex
Validations.xml
<formset>
<form-name=”/myFormAction”>
---------------------------
----------------------------
</form-name>
struts-config.xml
<form-beans>
<form-bean name=”myForm”
type=”--------“/>
</form-beans>
<action-mapping>
<action path=”/myFormAction”
name=”myForm”
type=………
/>
|
|
Benefit
|
It’s a clear cut way to say that this form has following validations.
|
Some times it happens that a single form is shared by many actions or
JSP pages so to configure a single validation for form would be overkill, we
are wasting time by validating all fields which are not related to our page.
A page can be distinguished using ‘Action’ so it is being used here to save us from wastage. |
Complete Example :
Will be posted on 09th July 2012.
8 comments:
Very Good comparison,can you please give me comparison between all available action forms.
Great comparison can you please provide Tiles sample program as well for struts 1.3.
You have written execute(AM,AF,HSR,HSR) in ActionForm I think execute(,,,,) is in Action right?
sorry Yup its my typo
Its just nothing but pure Awesomeness !! So simple to understand ! Thanks !
After examine a number of of the weblog posts in your web site now, and I really like your approach of blogging. I bookmarked it to my bookmark website record and might be checking again soon. Pls take a look at my site as properly and let me know what you think. online casinos
azure training
java training
salesforce training
hadoop training
SAP Secrity training
oracle sql plsql training
go langaunage training
azure training
java training
salesforce training
Post a Comment