Writing a custom converter to convert a phone number from the form entry (330) 555-1212 to 3305551212 to be stored in the database. That works, but I'm also trying to convert 3305551212 to (330) 555-1212 to be displayed on the form. That is not working, convertToString is never called.
Thanks in advance. public class PhoneConverter implements IConverter { public String convertToString(final Object value, Locale locale) { if (value == null) { return null; } String val = value.toString(); try { if (val.length() == 10) { val = "(" + val.substring(0, 3) + ") " + val.substring(3,7) + "-" + val.substring(7); } } catch (Exception e) { throw new ConversionException("'" + value + "' is not a valid Phone "); } return val.toString(); } public Object convertToObject(String value, Locale arg1) { // TODO Auto-generated method stub String rtnVal = ""; try { int len = value.length(); char c; for (int i = 0; i < len; i++) { c = value.charAt(i); if (Character.isDigit(c)) { rtnVal += c; } } return rtnVal; } catch (Exception e) { throw new ConversionException("'" + value + "' is not a valid Phone "); } } public class VendorEntry extends BasePage { RequiredTextField textPhoneNumber = new RequiredTextField("workPhone", USPhone.class); textPhoneNumber.add(StringValidator.maximumLength(10)); textPhoneNumber.add(new PatternValidator( "^[01]?[- .]?\\(?[2-9]\\d{2}\\)?[- .]?\\d{3}[- .]?\\d{4}$")); textPhoneNumber.add(new DojoBubbleValidationAjaxBehavior("onblur", bubble)); form.add(textPhoneNumber); } public class USPhone { private String phoneNumber; public String getPhoneNumber() { return phoneNumber; } public void setPhoneNumber(String phoneNumber) { this.phoneNumber = phoneNumber; } } // my bean used with //Form form = new Form("vendorEntryForm", new CompoundPropertyModel(vendorModel)) // public class Vendor implements java.io.Serializable { private String workPhone; -- View this message in context: http://www.nabble.com/Converter-1.3-beta2-convertToString-never-called-tp15812313p15812313.html Sent from the Wicket - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]