I have to say this is a much better approach than my implementation. Good post. Chris
-----Original Message----- From: Antony Joseph [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 01, 2005 1:30 PM To: Struts Users Mailing List Subject: Re: Is there a way to auto-trim String properties in DynaForms? Struts uses ConverterUtils to populate action forms. 1)Register the string converter which trims leading and trailing spaces with ConvertUtils. You want to do this during application initialization in a ServletContextListener or a Struts plugin TrimStringConverter trimString = new TrimStringConverter(); ConvertUtils.register(trimString, String.class); 2) The class which strips the leading and trailing spaces. public class TrimStringConverter implements Converter { /** * Trims leading and trailing white spaces. * @param type the type of the class * @param value the value * @return the trimmed string */ public Object convert(Class type, Object value) { if (value == null) return null; else return value.toString().trim(); } } ----- Original Message ----- From: "K.C. Baltz" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <user@struts.apache.org> Subject: Is there a way to auto-trim String properties in DynaForms? Date: Tue, 01 Mar 2005 09:53:20 -0800 > > I'm reposting this in the hopes that there is an answer out there. > > > It would be really nice if I could programmatically indicate that > > certain fields in a DynaForm should be automatically trimmed of > > whitespace. Is there a way to do this? > > Alternatively, is there a way to get the behavior of the > > "required" validation when using validwhen? "required" doesn't > > accept values that are nothing but whitespace whereas there's no > > way to test for this when using validwhen. > > K.C. Baltz > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] Antony Joseph Available for consulting http://www.logicden.com -- _______________________________________________ Find what you are looking for with the Lycos Yellow Pages http://r.lycos.com/r/yp_emailfooter/http://yellowpages.lycos.com/default .asp?SRC=lycos10 --------------------------------------------------------------------- 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]