Trimming Form Input

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Trimming Form Input

Joe Eckard
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

smime.p7s (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Trimming Form Input

cjhowe
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" <[hidden email]> 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

Reply | Threaded
Open this post in threaded view
|

Re: Trimming Form Input

David E Jones-2
In reply to this post by Joe Eckard

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


smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Trimming Form Input

Joe Eckard
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
>

smime.p7s (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Trimming Form Input

Andrew Sykes
In reply to this post by Joe Eckard
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 <[hidden email]>
Sykes Development Ltd
http://www.sykesdevelopment.com

Reply | Threaded
Open this post in threaded view
|

Re: Trimming Form Input

Jacques Le Roux
Administrator
In reply to this post by Joe Eckard
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" <[hidden email]>
To: <[hidden email]>
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
> >
>