You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Joel Trunick <jo...@webifysolutions.com> on 2005/01/25 18:01:10 UTC

Trimming White Space


Joel Trunick


Is there some clever way to trim white space from text fields, beginning
and end without coding each one?

Joel


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Trimming White Space

Posted by Ryan Mitchell <rm...@tcl.net>.
To achieve this I used a ValidField component with a subclass of 
StringValidator (see below).  Overkill if all
you want to do is trim whitespace, but I need to enforce string lengths.

package com.logitel.vxt.valid;

/* Extends StringValidator to trim() input field. */

import org.apache.tapestry.valid.StringValidator;
import org.apache.tapestry.valid.ValidatorException;
import org.apache.tapestry.form.IFormComponent;

public class TrimmedStringValidator extends StringValidator
{

    public Object toObject(IFormComponent field, String input) throws 
ValidatorException
    {
        return super.toObject(field, (input==null?null:input.trim()));
    }

}


--Ryan



Erik Hatcher wrote:

> You could use a custom IValidator attached to ValidField's to do this, 
> I believe.
>
>     Erik
>
> On Jan 25, 2005, at 12:01 PM, Joel Trunick wrote:
>
>>
>>
>> Joel Trunick
>>
>>
>> Is there some clever way to trim white space from text fields, beginning
>> and end without coding each one?
>>
>> Joel
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Trimming White Space

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
You could use a custom IValidator attached to ValidField's to do this, 
I believe.

	Erik

On Jan 25, 2005, at 12:01 PM, Joel Trunick wrote:

>
>
> Joel Trunick
>
>
> Is there some clever way to trim white space from text fields, 
> beginning
> and end without coding each one?
>
> Joel
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org