converters are not used for string<->string conversion because the
input is already a string.

-igor

On Tue, Oct 7, 2008 at 10:19 AM, Steve Thompson <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm attempting to create a custom validator for social security number
> strings.  I've got the following code for this:
>
>        static Pattern pattern = Pattern.compile("(\\d{3})[ \\-]*(\\d{2})[
> \\-]*(\\d{4})");
>
>        public final IConverter<String> getConverter(Class type)
>        {
>                return new IConverter<String>()
>                {
>
>                        public String convertToObject(String value, Locale 
> locale)
>                        {
>                                String result = "";
>                                result = value.substring(0, 3) + "-" + 
> value.substring(3, 5) + "-"
> + value.substring(5, 8);
>                                return result;
>                        }
>
>                        public String convertToString(String value, Locale 
> locale)
>                        {
>                                String result = "";
>                Matcher fit = pattern.matcher(value);
>                if(fit.find())
>                        for(int index = 1; index <= fit.groupCount(); index++)
>                                result += fit.group(index);
>                                return result;
>                        }
>
>                };
>        }
>
> When I use this with a text field, I can intercept the calls to
> convertToString.  However, convertToObject never seems to be getting
> called.  Is there something that I am doing wrong/not understanding?
>
> Thanks and best regards,
>
>
> Steve
>
> --
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to