Adding "Logic" and throwing error in Spring Roo Fields
I have a project created with Spring roo and I have a number field in one of my entities. I need to add some logic that this field can only take numbers that are powers of two and if it isn't then an error should be thrown to the user when trying to submit i.e. "Invalid input: not a power of two". I know what formula to use I'm just having trouble executing it on a sprin开发者_如何转开发g/roo project. i.e. Where/what file does this piece of code go into? How do I make sure an error is thrown so the user sees it.
I asked around and got a couple answers, namely this
1) client side way: In the entity create.jspx using javascript. 2) server side way. In entity controller loading the message error in the returning model object.
But I don't really understand how to do this.
Thanks.
You can use a custom validator for Spring with Spring Roo.
Take a look at the change password validator in the following article by Sujit Pal.
http://sujitpal.blogspot.com/2010/07/ktm-customizing-roo-security.html
All the best with Roo.
精彩评论