cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruno Dumon <br...@outerthought.org>
Subject Re: CForms: leading spaces dissapearing
Date Thu, 08 Jun 2006 15:32:14 GMT
On Thu, 2006-06-08 at 08:01 -0600, Jason Johnston wrote:
> Antonio Gallardo wrote:
> > Fernando.Matomira@thomson.com escribió:
> >> OK. I think I found it in Field.java, where it does
> >>
> >> newEnteredValue = newEnteredValue.trim();
> >>   
> > Hi Fernando,
> > 
> > Great you found it! You should can create a patch to optionally 
> > configure leading spaces and keeping the former behavior as the default 
> > behavior. WDYT?
> 
> FWIW I think this might best be implemented in the Convertor layer, that 
> seems most appropriate for converting untrimmed strings to trimmed and 
> vice versa.  A PlainStringConvertor for instance would keep 
> leading/trailing whitespace intact.  WDYT?
> 
> If Fernando doesn't want to create a patch I will do so since this has 
> annoyed me in the past as well.

Cool!

If you do it on the convertor layer, it would mean that every convertor
needs to handle whitespace for itself. For example, a date field
containing just a space would currently be treated as an empty input,
while otherwise it would be up to the date convertor to detect this.
This probably isn't a huge problem, a simple trim() and empty string
check at the start of the existing convertors could solve this.

If you go for the convertor approach, I would suggest to make the
default string convertor configurable, instead of creating multiple
convertors.

For example, using a whitespace attribute that could have the following
values:

whitespace="preserve|trim|trim-left|trim-right"

and possibly a trim-if-all-whitespace attribute to force trimming in
case the input contains only whitespace.

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org                          bruno@apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message