• Post Reply Bookmark Topic Watch Topic
  • New Topic

converter and validator  RSS feed

Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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 ]
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!