I feel the recommended solutions are complicated. 

Thanks.


--- On Fri, 10/2/09, Ernesto Reinaldo Barreiro <reier...@gmail.com> wrote:

> From: Ernesto Reinaldo Barreiro <reier...@gmail.com>
> Subject: Re: Can Wicket automatically remove beginning and trailing spaces in 
>  a text field?
> To: users@wicket.apache.org
> Date: Friday, October 2, 2009, 5:39 AM
> Why use aspects for 2 when you have
> IComponentInstantiationListener? All you
> have to do is set you components model to use the
> TrimmingModel pasted
> before on the listener. I didn't try it myself but I guess
> that should work.
> Best,
> 
> Ernesto
> 
> On Fri, Oct 2, 2009 at 10:57 AM, Bernhard Michal
> <michal.bernh...@tigra.cz>wrote:
> 
> > Afaik there is no way to set this behavior by some
> flag. But
> >
> > 1) You can extend TextField to wrap it's model with
> model which on
> > getObject() trim (ie. remove begging and trailing
> spaces) returning
> > string if Model's type is Sting (in other cases it
> doesn't make
> > sense)... when value is setted into model trimming is
> done by wicket
> > (see FormComponent#shouldTrimInput) automatically (in
> older version you
> > have to do this manually by overriding
> FormComponent#convertInput()
> > method)
> >
> > 2) you can do aspect (AspectJ?) to do the same as 1) -
> with aspect there
> > is no need to make new class of TextField's type so
> there is no need to
> > change the code base...
> >
> > 3) you can override implementation of coverters
> >
> > override Application#newConverterLocator() to
> >
> > protected IConverterLocator newConverterLocator() {
> >        ConverterLocator locator =
> new ConverterLocator();
> >        locator.set(String.class,
> new IConverter() {
> >
> >               
>            public Object
> convertToObject(String value,
> > Locale locale) {
> >               
>                
>         return convertToString(value,
> > locale);
> >               
>             }
> >
> >               
>             public String
> convertToString(Object value,
> > Locale locale) {
> >               
>                
>         return value.toString().trim();
> > // see trim() which remove trailing and beginning
> spaces
> >               
>             }
> >         
>    });
> >
> >        return locator;
> > }
> >
> > I didn't test it but you've got the idea... But this
> solution is really
> > bad, because if you want to turn off this behaviour
> (trimming) in some
> > cases
> > you can't do it without overriding for example
> Component#getConverter()
> > to convert it in default way and it's a mess.
> >
> > I recommend you to trim it by hand on Model level
> (make some wrapper
> > model to do it so) or on tier (layer) where you obtain
> data (data acces
> > layer? service level?). It depends on if spaces have
> some business
> > meaning. If yes do it on model level otherwise on that
> layer.
> >
> > Best wishes
> >
> > MB
> >
> > -----Original Message-----
> > From: David Chang [mailto:david_q_zh...@yahoo.com]
> > Sent: Friday, October 02, 2009 5:25 AM
> > To: users@wicket.apache.org
> > Subject: Can Wicket automatically remove beginning and
> trailing spaces
> > in a text field?
> >
> > How to set it up in a Wicket application? I would like
> to set it up in
> > the application level.
> >
> > Thanks!
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > For additional commands, e-mail: users-h...@wicket.apache.org
> >
> >
> 




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to