Thanks everyone, I really appreciate the input! On Aug 9, 4:34 pm, Chris Peterson <[email protected]> wrote: > No disrespect taken, Bob. That¹s one of the 1st things I had to Œget over¹ > when I really dove into OO / MVC coding, was that each person found a way > that seemed logical and worked for them, and stuck with it. I find that, as > long as you reason out what you are doing, and pick a way that makes sense > to you (and you can explain / justify down the road), you will be just fine. > So, Dean, you have now seen lots of different ways to accomplish what you > want (on many different levels), so you are now armed to determine your best > course of action, and stick with it throughout your app =) > > Have fun! > > Chris > > On 8/9/10 4:25 PM, "Bob Silverberg" <[email protected]> wrote: > > > > > > > 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] > >> <mailto:[email protected]> > >> <[email protected] <mailto:[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 <http://form.name> > >>>> > ) > >>>> ), just call > >>>> > user.setName( form.name <http://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<http://www.model-glue.com> > >>> Documentation:http://docs.model-glue.com<http://docs.model-glue.com> > >>> Bug Tracker:http://bugs.model-glue.com<http://bugs.model-glue.com> > >>> Blog:http://www.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] > >>> <mailto:[email protected]> > >>> To unsubscribe from this group, send email to > >>> [email protected] > >>> <mailto:[email protected]> > >>> For more options, visit this group at > >>>http://groups.google.com/group/model-glue?hl=en > >>> <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
