I will create a simple and isolated test case and debug that. S.
On 9/7/06, Johan Compagner <[EMAIL PROTECTED]> wrote: > Can you debug to see if the model that holds the number is getting the new > object > even if a validation error is thrown? > Because that shouldn't happen. But it seems like it happens at your case > because > if you say that the object after the bad submit is converted then it has to > come from > the model object because only the model object is converted. Not the raw > data which > should be displayed back when you have an error. > > johan > > > > On 9/7/06, Stefan Arentz <[EMAIL PROTECTED]> wrote: > > > I have an entity with a phoneNumber field. The format of this phone > number is +9912345678..., the international number notation. > > What I want to do is to have a text field that accepts phonenumbers in > different formats. For example 0612345678, "06 12345678" but also > +31612345678. Based on the locale I want to 'normalize' 0612345678 to > +3112345678. > > I would like people to be able to enter a number in any format in a > form field but have the model behind that to be updated to the > international notation. (+NNNNNNNNNNNN) > > I wrote a simple SimpleConverterAdapter implementation: > > public class PhoneNumberConverter extends SimpleConverterAdapter > { > public String toString(Object value) > { > if (value instanceof String) > { > String phoneNumber = (String) value; > > // Always match on an international phone number > > if (internationalPhoneNumberPattern.matcher > (phoneNumber).matches()) > { > return phoneNumber; > } > > // Recognize dutch mobile numbers (06NNNNNNNN) > > if (dutchPhoneNumber.matcher(phoneNumber).matches()) { > return "+31" + phoneNumber.substring(1); > } > } > > // If we cannot convert the object then throw an > IllegalArgumentException. > > throw new IllegalArgumentException("Cannot convert > non String objects"); > } > > public Object toObject(String value) > { > return value == null ? null : value.toString(); > } > } > > but the behaviour is very odd. When I enter '0612345678' in the form > and submit it, I get an error message saying that 0612345678 is not a > valid phone number (this is done by the PhoneNumberValidator) but the > phone number form field is updated to +316512345678. When I press > submit again then all is ok of course. > > I'm not sure what I'm doing wrong here. I simply want to accept input > in several formats. > > S. > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job > easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Wicket-user mailing list > Wicket-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/wicket-user > > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job > easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > > _______________________________________________ > Wicket-user mailing list > Wicket-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/wicket-user > > > ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user