I've never been a big fan of makeEventBean as it is so limited in its 
functionality. I also, no disrespect to Chris, can not imagine adding trimming 
code to each and every setter in my model. 

Those are just two of the reasons that I prefer to use a populate method in my 
model which addresses both of those issues. I simply pass the contents of the 
event into the populate method and it populates all of the properties, doing 
things like trimming, stripping HTML, dealing with nulls and many-to-ones.

I do acknowledge that this really is a controller concern, rather than a model 
concern, but I find that my solution just works so well for me that I'm able to 
conveniently forget about that. Plus, having the code in the model ensures 
integrity in the same way that adding logic to individual setters does. 

Cheers,
Bob

Sent from my iPhone

On 2010-08-09, at 3:59 PM, Charlie Griefer <[email protected]> wrote:

> While I agree with Chris, trimming the values in makeEventBean() might be 
> kind of cool.  
> 
> ColdBox has an event.getTrimValue( 'foo' ) method, which is just a nice 
> convenience instead of doing trim( event.getValue( 'foo' ) ).  While this is 
> more granular than makeEventBean(), I'm not sure there's a use case I can 
> think of where I wouldn't want the event values trimmed.  If nothing else, 
> maybe an optional argument in makeEventBean() to trim or not?
> 
> Just throwing it out there.  Dan seems like he's got way too much free time 
> on his hands, y'know? :)
> 
> On Mon, Aug 9, 2010 at 12:39 PM, [email protected] <[email protected]> wrote:
> Chris, that makes perfect sense. So instead of relying on the person
> sending data to the object to clean the extra whitespace, it will
> always be trimmed at the object level.
> 
> Thanks for the suggestion.
> 
> On Aug 9, 3:22 pm, Chris Peterson <[email protected]> wrote:
> > I would put the trimming inside your setFoo method on your model object
> > instead, that way regardless of where its coming from, it will always get
> > trimmed.
> >
> > ie:  Rather than call user.setName( trim( form.name ) ),  just call
> > user.setName( form.name ), then within the setName method, trim it before it
> > gets set internally, or before it gets persisted to your database.
> >
> > Chris Peterson
> >
> > On 8/9/10 3:17 PM, "[email protected]" <[email protected]> wrote:
> >
> >
> >
> > > I've been building MG apps for the last year or two and really love
> > > the framework. But there's a nagging question that has always bugged
> > > me, form field trimming (to remove white space). Currently, when I
> > > process a form submission, I create a new object (let's take a product
> > > order as an example) and individually call the the setter methods,
> > > passing in the trimmed form value like this: <cfset
> > > ProductOrder.setProductName(trim(arguments.event.getValue("productName")))
> > >  /
> > >> .
> >
> > > This works great, but can be quite tedious if I have a form with a lot
> > > of values. Last night I discovered the MakeEventBean method (only took
> > > me 2 years to find it) and thought that this would be perfect for
> > > speeding up my development process. However, after digging through the
> > > source code, I realize that it is not trimming the values. Does anyone
> > > have a good way that they handle this type of situation? Where are you
> > > trimming your values?
> >
> > > Thanks for any insight.
> >
> > > Dean
> 
> --
> Model-Glue Sites:
> Home Page: http://www.model-glue.com
> Documentation: http://docs.model-glue.com
> Bug Tracker: http://bugs.model-glue.com
> Blog: http://www.model-glue.com/blog
> 
> You received this message because you are subscribed to the Google
> Groups "model-glue" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/model-glue?hl=en
> 
> 
> 
> -- 
> Charlie Griefer
> http://charlie.griefer.com/
> 
> I have failed as much as I have succeeded. But I love my life. I love my 
> wife. And I wish you my kind of success.
> -- 
> Model-Glue Sites:
> Home Page: http://www.model-glue.com
> Documentation: http://docs.model-glue.com
> Bug Tracker: http://bugs.model-glue.com
> Blog: http://www.model-glue.com/blog
>  
> You received this message because you are subscribed to the Google
> Groups "model-glue" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/model-glue?hl=en

-- 
Model-Glue Sites:
Home Page: http://www.model-glue.com
Documentation: http://docs.model-glue.com
Bug Tracker: http://bugs.model-glue.com
Blog: http://www.model-glue.com/blog

You received this message because you are subscribed to the Google
Groups "model-glue" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/model-glue?hl=en

Reply via email to