wicket-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ernesto Reinaldo Barreiro <reier...@gmail.com>
Subject Re: Can Wicket automatically remove beginning and trailing spaces in a text field?
Date Fri, 02 Oct 2009 07:56:37 GMT
Never done it myself, and don't know if it is a better way to do it, but:
protected IConverterLocator
{
return new ConverterLocator();
}

can be overriden to return your own converter locator and... plug there a
default converter (for Strings?) that will trim strings...

If you want to do this for a particular kind of component, e.g. textareas,
another possibility would be to use a component instantiation listener and
wrap the component model with a trimming model, e.g.

import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

public class TrimmingModel extends Model<String> {

private static final long serialVersionUID = 1L;
 private IModel<String> model;

public TrimmingModel(IModel<String> model) {
this.model = model;
}
 @Override
public void setObject(String object) {
if(object != null)
this.model.setObject(object.trim());
this.model.setObject(object);
}
 @Override
public String getObject() {
return this.model.getObject();
}
}

Best,

Ernesto

On Fri, Oct 2, 2009 at 5:24 AM, David Chang <david_q_zhang@yahoo.com> wrote:

> 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-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message