What is the difference between actionform and validatorform
When the form is submitted according to OK, it is verified first. If the verification is successful, continue to use the validate method for verification. If the verification is unsuccessful, the verification process is aborted and the validate method will not be used. DynaActionForm is dynamic and inherited from ActionForm.
The reason for this is because it does not require FormBean, but sets form field properties of form in form-property in struts-config. The advantage is to reduce the increase of formbean in the large-scale development process and make the program bloated, which brings great inconvenience to maintenance and upgrade. If the member registration information is read from the dynamic form instance:.
Java enterprise development example. PS: In practice, it is concluded that if in If the validate method is rewritten in ValidatorForm, the program will not be verified from the two files validation-rules. Instead, it will execute the contents of the rewritten validate method.
This method will still be executed, and the default I will verify from the above two documents. You can do declarative validation by defining rules in XML config files like validation-rule.
Since Struts is one of the popular Web MVC frameworks, you can also use its validation framework on any Java web application implemented using Struts. Now, coming back to the question, what is the actual difference between ValidatorForm and ValidatorActionForm in Struts? They both look quite similar, right? Well, even though both ValidatorForm and ValidatorActionForm provides validation support and can be used to validate form fields in Struts application, there is a subtle difference between them.
The ValidatorForm class uses the "form name" to perform validation, while ValidatorActionForm class uses the "action name" to perform validation in Struts. There are clear benefits of each approach.
When you use ValidatorForm then by looking at the struts-config. But, that's not the case when you use ValidatorActionForm , though it provides a more practical way to validate form fields of a particular form in Struts. Sometimes it happens that a single form is shared among many actions and JSP pages, which means configuring a single validation for the form would be unnecessary. You will waste time on validating fields which are not related to our page.
A page can be distinguished using 'Action' so by using ValidatorActionForm you can save a lot of unnecessary validation. Difference between ValidatorForm and ValidatorActionForm in Struts Before looking at the difference between these two classes, let's first try to revise some basics about Validator framework in Struts. The Validator Framework is used to provide validation of form fields e. The first one validator-rules. You can add new validation rules by adding new entries in this file.
Featured on Meta. Now live: A fully responsive profile. Related 0. Hot Network Questions. Question feed.
Stack Overflow works best with JavaScript enabled.
0コメント