This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
I am using struts 2 in my application. I have to implement validation in one of my form. I was able to do the basic validation using the struts default validators.
My issue is that, I have to submit the form only when the integer value I entered is greater than a predefined value which is database driven. I have no idea in writing the interceptor and calling it in struts.xml
There's absolutely no reason to do this in an interceptor, and IMO an interceptor would be an inappropriate place to do it: interceptors are generally for application-wide functionality.
Just implement a validate() method, call super.validate() to run the XML- and/or annotation-driven validation, then do your own DB-driven validation. (This assumes your action extends ActionSupport, if not, you'll need to implement ValidationAware and Validatable.)
(I'd also probably load the value into the application scope on application startup to avoid having to go to the database all the time for such a simple requirement; if the value is updateable simply use a synchronized value in app scope and change it, as well as the DB table, when it's updated. That's a separate issue, though.)
Just implement a validate() method, call super.validate() to run the XML- and/or annotation-driven validation, then do your own DB-driven validation. (This assumes your action extends ActionSupport, if not, you'll need to implement ValidationAware and Validatable.)
David thanks for the reply.. but as i said i am new to this. So if you don't mind can you explain the above. Presently I validate using the javascript. Its working fine. but i would really like to do the validation through struts.