The second way is to define a separate object, called a Validator, which validates your model object. To do this, first create a class whose name has the pattern ${model}Validator, where ${model} is the capitialized form of the model expression, such as booking. Then define a public method with the name validate${state}, where ${state} is the id of your view-state, such as enterBookingDetails.
Thus, since your model
attribute is ccForm
, the validator Class must be named CcFormValidator
. (Or rename your model
attribute.)
(Also, I think your JSP is going to have problems using modelAttribute="ccf"
instead of "ccForm"
. The model name needs to match across flow.xml, JSPs, and validators.)