JavaScript support
In web applications, there are many opportunities to use JavaScript. Although many books mentioning that customers may have the implementation of JS from the browser, don't use it completely, it seems that it doesn't seem to be. For example, some complex UIs must be implemented by JS (such as pull-down menus, etc.). So what is the JS authentication of the Validation framework not supported?
The answer is: Of course. The specific approach is:
- Add οnsubmit = "Return ValidateEditform (this) in the page HTML: Form Tag; (specific syntax: Validate defined in the validation.xml file);
- Add:
So 2 steps. Although the Validation framework is very easy to use, it still needs attention.
Use attention
1. After using the Validation framework, Form must derive from the ValidatorForm, and must first call the validate method of the base class in your validate method. For methods that start with Dyna to create a FORMBEAN reader, you must also change the FORM with Validator with DYNA.
2. Note DynaValidatorForm (ValidatorForm) and DynavalidatorActionform (ValidatorActionform). At the beginning, I didn't understand the difference between these two, and later I obtained the difference from the online article. The main perspective of the former is FORMBEAN, while the latter's perspective is Action.
When FormBean is used by different Action, for different Actions, it is very small for use in the material set of FORMBEAN. At this point, if you still use the FORMBEAN as the main body, it will cause abnormal use of other Actions. Therefore, the Struts proposed DynavalidatorActionform (ValidatorActionform). At this time, the Name property of the FORM tag in Validation.xml is changed to the path properties of Action, and because there is Attribute and Name attribute in the action, the Validation Framework can get the corresponding FORMBEAN according to this action. example: