I'm glad you guys are having this conversation. While we are always happy to
have feature requests, in this case, it's not really something we'll
provide. Here's why:

*Not every application wants to have the inputs trimmed. *

But, that doesn't mean YOU can't make this work in your application. More
importantly, you can do this without screwing with Model Glue internals..
(which would be very bad.)

See, Model Glue is built for you to extend. You can extend Model Glue by
providing your own implementation of our objects, and using ColdSpring to
wire them together.

Here is a three step account of how to do this very thing:



Model Glue uses populators to handle the population of the event by the
respective input scopes.

*Step 1: *
**Go into the Model Glue framework and copy 3 files into your Model
directory:
/ModelGlue/gesture/eventrequest/population/FormPopulator.cfc
/ModelGlue/gesture/eventrequest/population/StructBasedPopulator.cfc
/ModelGlue/gesture/eventrequest/population/URLPopulator.cfc

When you open the FormPopulator and the URL populator, you can see both
extends the StructBasedPopulator. We'll make our change to the
StructBasedPopulator:

*Step 2:*
Change the populate method to the code here:
http://modelglue.pastebin.com/Lvp9HEkm

(See how it'll trim all simple values?)


Now, we just need to tell Model Glue to use OUR version of these files,
rather than the version that ships with the framework:
*
*
*Step 3: *

**Open your application specific ColdSpring and add the following
configuration:  http://modelglue.pastebin.com/mCc91fLc

(see how the names of the beans correspond with the names of beans inside
the Model Glue coldspring file: /ModelGlue
(Gesture)/gesture/configuration/ModelGlueConfiguration.xml


What'll happen now is, when your application loads, Model Glue will use the
custom populators that trim all the values, rather than the built in
objects. More importantly, you've changed how Model Glue works, without
altering Model Glue. That means you are free to update the framework without
fear of causing issues. Moreover, since not all applications want all Form
and URL values trimmed, only applications with the ColdSpring configuration
will have this new trimming functionality.

Your application remains portable. Model Glue remains pure.


Wasn't that fun?

DW






On Mon, Aug 9, 2010 at 4:01 PM, todd sharp <[email protected]> wrote:

> Dean:
>
> Just curious - are you also doing any kind of method to prevent a user from
> entering scripts into text fields?
>
> Todd
>
>
> On Mon, Aug 9, 2010 at 3: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]<model-glue%[email protected]>
>> For more options, visit this group at
>> http://groups.google.com/group/model-glue?hl=en
>>
>
>
>
> --
> Todd Sharp
> Sharp Interactive, LLC
> http://slidesix.com -- Multimedia Enabled Presentation Sharing
> IM:  [email protected]
> Blog:  http://cfsilence.com
> Twitter: cfsilence | slidesix
>
>  --
> 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]<model-glue%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/model-glue?hl=en
>



-- 
William Osler - "We are here to add what we can to life, not to get what we
can from life."

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