You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by "J. Eckard" <jo...@redrocketcorp.com> on 2007/01/10 17:55:07 UTC

Trimming Form Input

What would be the best way to trim form input that is passed to stock 
ofbiz services like "createPerson" and "createPostalAddress"? Add a new 
<trim> operation to the simple-map-processors? Use an entity ECA? I'd 
like to avoid creating people with names like "John  ", " Doe   ", etc. 
and address lines like "Suite 200    ".

-Joe

Re: Trimming Form Input

Posted by Jacques Le Roux <ja...@les7arts.com>.
These 3 ideas seems good to me.

1 + 2 are thought to covert all EnvOperations I presume
3 (Joe's) covers map-processor case

I dont know enought to see something missing here, perhaps EventOperations ?

Jacques

----- Original Message ----- 
From: "J. Eckard" <jo...@redrocketcorp.com>
To: <of...@incubator.apache.org>
Sent: Wednesday, January 10, 2007 9:05 PM
Subject: Re: Trimming Form Input


> What about making the <copy> map-processor operation automatically trim 
> values that are String objects? Although there may be cases where you 
> don't want this... maybe add an attribute called "preserve-whitespace" 
> in addition to "set-if-null" and "replace"?
> 
> (I realize this won't fix the createPerson problem since that service 
> doesn't use a map-processor, but that could be a different subject)
> 
> -Joe
> 
> On Jan 10, 2007, at 2:22 PM, David E Jones wrote:
> 
> >
> > Good question. I guess it depends on how universal we want to make 
> > this. For doing it manually I can think of a couple of ways to handle 
> > it in simple-methods:
> >
> > 1. add a trim-entries operation to trim all entries in a Map or List
> > 2. add a trim attribute to the set operation, the set-*-fields 
> > operations, etc
> >
> > Anyone have any thoughts or preferences on this?
> >
> > -David
> >
> >
> > On Jan 10, 2007, at 9:55 AM, J. Eckard wrote:
> >
> >> What would be the best way to trim form input that is passed to stock 
> >> ofbiz services like "createPerson" and "createPostalAddress"? Add a 
> >> new <trim> operation to the simple-map-processors? Use an entity ECA? 
> >> I'd like to avoid creating people with names like "John  ", " Doe   
> >> ", etc. and address lines like "Suite 200    ".
> >>
> >> -Joe
> >
> 

Re: Trimming Form Input

Posted by "J. Eckard" <jo...@redrocketcorp.com>.
What about making the <copy> map-processor operation automatically trim 
values that are String objects? Although there may be cases where you 
don't want this... maybe add an attribute called "preserve-whitespace" 
in addition to "set-if-null" and "replace"?

(I realize this won't fix the createPerson problem since that service 
doesn't use a map-processor, but that could be a different subject)

-Joe

On Jan 10, 2007, at 2:22 PM, David E Jones wrote:

>
> Good question. I guess it depends on how universal we want to make 
> this. For doing it manually I can think of a couple of ways to handle 
> it in simple-methods:
>
> 1. add a trim-entries operation to trim all entries in a Map or List
> 2. add a trim attribute to the set operation, the set-*-fields 
> operations, etc
>
> Anyone have any thoughts or preferences on this?
>
> -David
>
>
> On Jan 10, 2007, at 9:55 AM, J. Eckard wrote:
>
>> What would be the best way to trim form input that is passed to stock 
>> ofbiz services like "createPerson" and "createPostalAddress"? Add a 
>> new <trim> operation to the simple-map-processors? Use an entity ECA? 
>> I'd like to avoid creating people with names like "John  ", " Doe   
>> ", etc. and address lines like "Suite 200    ".
>>
>> -Joe
>

Re: Trimming Form Input

Posted by David E Jones <jo...@undersunconsulting.com>.
Good question. I guess it depends on how universal we want to make  
this. For doing it manually I can think of a couple of ways to handle  
it in simple-methods:

1. add a trim-entries operation to trim all entries in a Map or List
2. add a trim attribute to the set operation, the set-*-fields  
operations, etc

Anyone have any thoughts or preferences on this?

-David


On Jan 10, 2007, at 9:55 AM, J. Eckard wrote:

> What would be the best way to trim form input that is passed to  
> stock ofbiz services like "createPerson" and "createPostalAddress"?  
> Add a new <trim> operation to the simple-map-processors? Use an  
> entity ECA? I'd like to avoid creating people with names like  
> "John  ", " Doe   ", etc. and address lines like "Suite 200    ".
>
> -Joe


Re: Trimming Form Input

Posted by Andrew Sykes <an...@sykesdevelopment.com>.
David,

I'm trying to understand the advantage of your suggestions over Joe's
original suggestion?

Can you elaborate a little please?

It seems this is only a problem with input from html forms so simple-
map-processor is an obvious choice for a place to deal with it

Sorry if this is a stupid question...

- Andrew


On Wed, 2007-01-10 at 12:22 -0700, David E Jones wrote:
> Good question. I guess it depends on how universal we want to make  
> this. For doing it manually I can think of a couple of ways to handle  
> it in simple-methods:
> 
> 1. add a trim-entries operation to trim all entries in a Map or List
> 2. add a trim attribute to the set operation, the set-*-fields  
> operations, etc
> 
> Anyone have any thoughts or preferences on this?
> 
> -David
> 
> 
> On Jan 10, 2007, at 9:55 AM, J. Eckard wrote:
> 
> > What would be the best way to trim form input that is passed to  
> > stock ofbiz services like "createPerson" and "createPostalAddress"?  
> > Add a new <trim> operation to the simple-map-processors? Use an  
> > entity ECA? I'd like to avoid creating people with names like  
> > "John  ", " Doe   ", etc. and address lines like "Suite 200    ".
> >
> > -Joe
> 
-- 
Kind Regards
Andrew Sykes <an...@sykesdevelopment.com>
Sykes Development Ltd
http://www.sykesdevelopment.com


Re: Trimming Form Input

Posted by Chris Howe <cj...@yahoo.com>.
Depends on what you're using to process/validate the
form.  

In javascript to validate/process on the client side
something like:

   var str = "  this is a test   ";

   str = str.replace(/^\s*|\s*$/g,"");


If you're passing it to validate/process on the server
side
in java

   str.trim()
or in simple-method

        <call-object-method method-name="trim"
obj-map-name="parameters" obj-field-name="str"
ret-field-name="newStr"/>

--- "J. Eckard" <jo...@redrocketcorp.com> wrote:

> What would be the best way to trim form input that
> is passed to stock 
> ofbiz services like "createPerson" and
> "createPostalAddress"? Add a new 
> <trim> operation to the simple-map-processors? Use
> an entity ECA? I'd 
> like to avoid creating people with names like "John 
> ", " Doe   ", etc. 
> and address lines like "Suite 200    ".
> 
> -Joe