You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "chadmichael@excite.com" <ch...@excite.com> on 2006/01/26 17:22:07 UTC

extra white space on form input




When struts takes the data from the request and populates your form, does it automatically trim whitespace?  I think this might be answered from the particulars of HTML rather than struts.  Perhaps the question is really whether html trims whitespace before building the request.  If id doesn't, does struts?  


_______________________________________________
Join Excite! - http://www.excite.com
The most personalized portal on the Web!



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


Re: extra white space on form input

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
In fact, Java Web Parts has such a filter:

http://http://javawebparts.sourceforge.net/javadocs/javawebparts/filter/ParameterMungerFilter.html

And in fact, if you wanted to do it client-side, JWP can help there too:

http://javawebparts.sourceforge.net/javadocs/javawebparts/taglib/jstags/FullTrimTag.html

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM: fzammetti
Yahoo: fzammetti
MSN: fzammetti@hotmail.com

On Thu, January 26, 2006 12:27 pm, Tamas Szabo said:
> On 1/27/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
>>
>> On 1/26/06, chadmichael@excite.com <ch...@excite.com> wrote:
>> > When struts takes the data from the request and populates your form,
>> > does it automatically trim whitespace?  I think this might be answered
>> > from the particulars of HTML rather than struts.  Perhaps the question
>> > is really whether html trims whitespace before building the request.
>> If
>> > id doesn't, does struts?
>>
>> Nope, neither Struts nor your browser (HTML) trims whitespace on the
>> data
>> it submits.  It really wouldn't be correct if either did because it
>> would
>> then not be an accurate representation of what was entered by the user
>> (or
>> transmitted by the client if its another machine).  I mean, if someone
>> enters "   Hello   " instead of "Hello", who's to say the first should
>> be
>> transformed to the second?  You may have a use case that says those are
>> two distinct values that you have to be able to differentiate.  It might
>> be nice if you could tell Struts (or the browser) to automatically trim
>> all parameters, but as it is today, you cannot, you will have to write
>> the
>> code to do this, either on the client or the server.
>
>
> You could probably define and register a Converter that does the trimming
> for you.
> Or you coud use a Filter.
>
> These apply if you want to handle it on hte server side...
>
> Tamas
>


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


Re: extra white space on form input

Posted by Tamas Szabo <sz...@gmail.com>.
On 1/27/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
>
> On 1/26/06, chadmichael@excite.com <ch...@excite.com> wrote:
> > When struts takes the data from the request and populates your form,
> > does it automatically trim whitespace?  I think this might be answered
> > from the particulars of HTML rather than struts.  Perhaps the question
> > is really whether html trims whitespace before building the request.  If
> > id doesn't, does struts?
>
> Nope, neither Struts nor your browser (HTML) trims whitespace on the data
> it submits.  It really wouldn't be correct if either did because it would
> then not be an accurate representation of what was entered by the user (or
> transmitted by the client if its another machine).  I mean, if someone
> enters "   Hello   " instead of "Hello", who's to say the first should be
> transformed to the second?  You may have a use case that says those are
> two distinct values that you have to be able to differentiate.  It might
> be nice if you could tell Struts (or the browser) to automatically trim
> all parameters, but as it is today, you cannot, you will have to write the
> code to do this, either on the client or the server.


You could probably define and register a Converter that does the trimming
for you.
Or you coud use a Filter.

These apply if you want to handle it on hte server side...

Tamas

Re: extra white space on form input

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
On 1/26/06, chadmichael@excite.com <ch...@excite.com> wrote:
> When struts takes the data from the request and populates your form,
> does it automatically trim whitespace?  I think this might be answered
> from the particulars of HTML rather than struts.  Perhaps the question
> is really whether html trims whitespace before building the request.  If
> id doesn't, does struts?

Nope, neither Struts nor your browser (HTML) trims whitespace on the data
it submits.  It really wouldn't be correct if either did because it would
then not be an accurate representation of what was entered by the user (or
transmitted by the client if its another machine).  I mean, if someone
enters "   Hello   " instead of "Hello", who's to say the first should be
transformed to the second?  You may have a use case that says those are
two distinct values that you have to be able to differentiate.  It might
be nice if you could tell Struts (or the browser) to automatically trim
all parameters, but as it is today, you cannot, you will have to write the
code to do this, either on the client or the server.

Frank


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


Re: extra white space on form input

Posted by Michael Jouravlev <jm...@gmail.com>.
No. Why should it?

On 1/26/06, chadmichael@excite.com <ch...@excite.com> wrote:
>
>
>
>
> When struts takes the data from the request and populates your form, does it automatically trim whitespace?  I think this might be answered from the particulars of HTML rather than struts.  Perhaps the question is really whether html trims whitespace before building the request.  If id doesn't, does struts?

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