jQuery in Action, 3rd edition
The moose likes JSF and the fly likes Custom convertor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Custom convertor" Watch "Custom convertor" New topic

Custom convertor

Shahir Deo
Ranch Hand

Joined: Mar 19, 2013
Posts: 80

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.


Knowledge enlivens the soul.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

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.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link: http://aspose.com/file-tools
subject: Custom convertor
It's not a secret anymore!