Thanks!
________________________________ From: Adrian Ost <adrian....@mindmatics.de> To: Struts Users Mailing List <user@struts.apache.org> Sent: Tue, September 14, 2010 4:26:55 PM Subject: AW: [S2] trim textfield This one worked for me. public class StringTrimInterceptor extends AbstractInterceptor { /* (non-Javadoc) * @see com.opensymphony.xwork2.interceptor.AbstractInterceptor#intercept(com.opensymphony.xwork2.ActionInvocation) */ @Override public String intercept(ActionInvocation pActionInvocation) throws Exception { // trim params Map params = pActionInvocation.getInvocationContext().getParameters(); for (Object o : params.entrySet()) { Entry e = (Entry) o; if (e.getValue() instanceof String[]) { String[] values = (String[]) e.getValue(); List<String> newvalues = new ArrayList<String>(); for (String string : values) { newvalues.add(string.trim()); } e.setValue(newvalues.toArray(new String[newvalues.size()])); } } pActionInvocation.getInvocationContext().setParameters(params); return pActionInvocation.invoke(); } } <interceptor name="stringTrimInterceptor" class="xxx.core.interceptors.StringTrimInterceptor"> </interceptor> -- ------------------------------------------- Adrian Ost Applikations-Entwickler Tel.: +49 89 322986 591 Fax: +49 89 322986 570 Mobile: +49 172 8389 591 E-Mail: adrian....@mindmatics.de ------------------------------------------- www.mindmatics.com www.mopay.com www.clanmo.com MindMatics AG, Marcel-Breuer-Str. 18 80807 Muenchen, Germany ------------------------------------------- The contents of this e-mail are confidential. If you received this e-mail in error, please notify us immediately and delete the e-mail. Ust-IdNr. DE211603599 Registergericht München: HRB 131369 Vorstand: Ingo Lippert (Vorsitzender), Christian Hinrichs, Armin Barbalata Aufsichtsratsvorsitzender: Olav Ostin ------------------------------------------- > -----Ursprüngliche Nachricht----- > Von: mailtolouis2020-str...@yahoo.com > [mailto:mailtolouis2020-str...@yahoo.com] > Gesendet: Dienstag, 14. September 2010 17:20 > An: Struts Users Mailing List > Betreff: Re: [S2] trim textfield > > Hi Dave, > > Hope u can commit it when u free, it quite useful though > > > > > ________________________________ > From: Dave Newton <davelnew...@gmail.com> > To: Struts Users Mailing List <user@struts.apache.org> > Sent: Tue, September 14, 2010 3:55:03 PM > Subject: Re: [S2] trim textfield > > Not by default. I'd probably just write an interceptor with > optional "excludes"... I had one I was going to commit but > never did then I was busy for a year. > > On Tue, Sep 14, 2010 at 10:50 AM, > <mailtolouis2020-str...@yahoo.com> wrote: > > Hi, > > > > In struts2 is there anyway to set to trim the value in textfield or > > textarea when it set to action/model? > > > > Regards > > LV > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org