This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I have a field named 'Dog' I want user to enter input in following way:
dog name-owner name
For example: tommy-micheal is valid, doggie-ramlal is also valid, whereas pappi is not valid.
I have written a validator for this:
I also want to convert it into following format:
'tommy-micheal' will get converted to 'micheal has a dog tommy'. I do have written convertor for this:
But I am facing issues because of strange behavior of framework.
It "converts" first and then "validate".
Now if user enters something inappropriate. It doesn't validate, goes into convertor (in gerAsObject() method) and gives 'ArrayIndexOutOfBoundsException' becuase of that split method. I can put a check here but why it doesn't validate first?
Because of this error, dog object doesn't get constructed properly and I get 'ClassCastException' in getAsString method of convertor. Otherwise I don't get any 'ClassCastException' in this method in user enters value in proper format.
I know people who has faced similar problem will understand this.
Let me know what you suggest.
[ January 25, 2008: Message edited by: ankur rathi ]