aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Custom convertor" Watch "Custom convertor" New topic
Author

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.

Thanks


Knowledge enlivens the soul.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16142
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
Don't get me started about those stupid light bulbs.
 
subject: Custom convertor