Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Custom convertor

 
Shahir Deo
Ranch Hand
Posts: 80
Hibernate Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I have created JSF Registration Page in which i need the contact number of user be appended with CountryCode given their country name.

Ex: In India Country Code is +91 it shld be appended with the "Number" which is given by user.

I Thought of Using Custom Convertors but there is some problem it is not returning the value.

If you have any idea or code. i request to share.

Thanks
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17989
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A Convertor is not a good place to do this, for several practical reasons, but the abstract reason why you shouldn't do it there is that a Convertor should not be altering data.

What I would generally do would be something like this. I'd lay out a page with the inputs, including country selection and phone number, with a separate control for the country code part of the phone number. Depending on your preferences/needs, this control might be display-only. You could then attach AJAX functionality so that whenever the country selection control value was changed, a backing bean action method (AJAX listener) computed the corresponding country code and set the backing bean property for the country code accordingly.

A variation on this where you don't maintain a separate control for the country code is to make the AJAX listener code strip any detected previous country code from the input phone number and replace it with the new country code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic