Sounds good... Not sure how far down the path of parameterizing messages you want to go... WW2 has the ability to parameterize messages with named params using the ValueStack...
> -----Original Message----- > From: Dick Zetterberg [mailto:[EMAIL PROTECTED] > Sent: Monday, May 12, 2003 6:09 PM > To: [EMAIL PROTECTED] > Subject: Re: [OS-webwork] Avoid IllegalArgumentException WW1.3.0 > > > Ok, so let's change this then so that editors for object > types do not throw exception for null or empty strings. This > means that we must add a new set of editors for the primitive > types. Those editors should work as today and throw > exceptions on null/empty values. > > We should perhaps fix the i18n issue so that the error > message is not hardcoded to "Unable to set value for" as > well? One way would be to create a new exception > PropertyEditorException that extends > IllegalArgumentException. The editors would then throw the > new exception instead. It would take a bundle key and an > object (the value that was tried to be set) as parameters. > Then ActionSupport is changed so that the > addIllegalArgumentException method checks if the exception is > a PropertyEditorException. In that case it calls the getText > method of ActionSupport to retrieve the actual message. And > formats it using a MessageFormat before calling addError. > Something like: > > public void addIllegalArgumentException(String fieldName, > IllegalArgumentException e) > { > String msg = e.getMessage(); > if (e instanceof PropertyEditorException) > { > msg = getPropertyEditorMessage(fieldName, > (PropertyEditorException) e); > } > addError(fieldName, msg); > } > > protected String getPropertyEditorMessage(String > fieldName, PropertyEditorException pe) > { > String bundleText = getText(pe.getMessage()); > Object[] propertyValues = pe.getPropertyValues(); > if (propertyValues == null) > return bundleText; > else > return MessageFormat.format(bundleText, propertyValues); > } > > And then we would add a ActionSupport.properties file to the > distribution with default messages in english like: > > BAD_INTEGER=The value {0} is not a valid integer > EMPTY_INTEGER=An integer must be entered BAD_INTEGEROBJ=The > value {0} is not a valid integer ... > > What do you think? > > Cheers, > > Dick Zetterberg > [EMAIL PROTECTED] > > > ----- Original Message ----- > From: "Lars Fischer" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Saturday, May 10, 2003 9:51 AM > Subject: Re: [OS-webwork] Avoid IllegalArgumentException WW1.3.0 > > > > It would be nice if this would be changed for 1.3.1. It should not > > break backwards compatibility because if an object value is not > > allowed to be > null > > this should be caught by some kind of logical validation -> > you have > > to > fill > > in the user name but not the phone number. > > > > Null is a legal value for an object so it's not an error (think of > database > > columns). The IllegalArgumentException should only be > thrown when you > > try to fill in 'ABC' for an Integer object for example. > > > > In WW1.2 I wrote my own validator for type conversion with > reflection. > > The error message is not like "Unable to set value for" because the > > normal user does not always know what this means (and maybe > English is > > not his language). IMO it's better to say "ABC" is not valid for a > > number field. > > > > > > > ------------------------------------------------------- > Enterprise Linux Forum Conference & Expo, June 4-6, 2003, > Santa Clara The only event dedicated to issues related to > Linux enterprise solutions www.enterpriselinuxforum.com > > _______________________________________________ > Opensymphony-webwork mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork > ------------------------------------------------------- Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara The only event dedicated to issues related to Linux enterprise solutions www.enterpriselinuxforum.com _______________________________________________ Opensymphony-webwork mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork