I am new to struts. I download some sample code and I got lost when reading it. It seems none of the form extends ValidatorForm, they all extend ActionForm. So it appears to me this application is not using struts validator, right ? But I found the code includes validation.xml and validation-rules.xml files. So is it possible for a struts application use struts validator without extending ValidationForm for its form beans ?
Joined: Feb 15, 2005
There are two ways of validating in Struts:
Extending ActionForm and overriding the validate method with your own validation code
Overriding ValidatorForm and defining your validations in the validator.xml file
So, in answer to your question, it is possible to validate in Struts without extending ValidatorForm, but only if you write code, rather than using the validator.xml fil.
Appreciate your response. Just have few more questions to confirm--
2. regardless of client or server side struts validation, as long as it is struts validation, the validation only happens after you click the submit button, correct (the difference is for client it may intercept the form before sending to server, and server side validation is done after it is sent to server) ?
3. You said if the form extends ActionForm instead of ValidationForm, then the validation-rules.xml and validation.xml are useless, and the only validation logic should be in the form class ?
4. I notice that in some form, after I filled in some text in a text field and moved to the next field, sometimes it immediately pops up an alert telling me I entered wrong format for last text field. At that point I hvaen't clicked submit button yet. For such validation, can I say this is not struts validation, it may be java script validation, correct ?