Let me clarify that last bit - the JS validations are not present in any of
my HTML templates, but the view does ask for the JS validations at the end
of the request, after all of the HTML has been generated.

Bob


On Jan 11, 2008 10:05 AM, Bob Silverberg <[EMAIL PROTECTED]> wrote:

> Because the validation rules are separated from the implementation, I can
> easily switch implementations.  I have a JavaScript renderer that takes the
> validation rules and generates the JS, so I can replace that if I want to
> change implementations.  This scheme also means that the JS validations are
> not present in any of my view code.
>
> Bob
>
>
>
> On Jan 11, 2008 10:00 AM, Brian Kotek <[EMAIL PROTECTED]> wrote:
>
> > Does this handle varying JavaScript validation implementations, are are
> > you basically committed to using one in particular?
> >
> >
> > On Jan 11, 2008 9:12 AM, Bob Silverberg < [EMAIL PROTECTED]>
> > wrote:
> >
> > > Here's a high-level summary of what I do:
> > >
> > > 1. I define all of my validation rules in the model, so they are
> > > defined in one place only.  E.g., the User model contains the
> > > validation rules for Users.
> > > 2. When I need to generate validations I ask the model for the
> > > validations, which in my implementation are returned in an array.
> > > 3. When I need to process validations, I just loop through the array
> > > and generate a validation for each validation rule.  I can do this as part
> > > of my Update routine for server side validations and I use these to 
> > > generate
> > > my Javascript validations in my view code just before rendering the page.
> > >
> > > So, I have all of the validation rules specified in one location only
> > > (the model), when I need them (either to render a screen or to do an 
> > > update)
> > > I just ask the model for them, and I have two versions of code that can 
> > > use
> > > those validations rules to implement actual validations (one for server 
> > > side
> > > and one for Javascript).
> > >
> > > HTH,
> > > Bob
> > >
> > >
> > >
> > > On Jan 11, 2008 4:46 AM, Alan Livie < [EMAIL PROTECTED]>
> > > wrote:
> > >
> > > >
> > > > I still haven't come up with a solution for this.
> > > >
> > > > I am working on a project removing duplicated code, creating a basic
> > > > domain model from a procedural app but one place where business
> > > > rules
> > > > are being duplicated is in the js validation files that check forms
> > > > on
> > > > the site.
> > > >
> > > > I could generate the js from the CFC's that handle the business
> > > > rules
> > > > but not sure the best way to go about this.
> > > >
> > > > I could also use AJAX to do the validation server-side but I'm also
> > > > uncomfortable having the server do extra work when it doesn't need
> > > > to
> > > > (and be slightly slower than client-side js)
> > > >
> > > > Someone mentioned on this group that Brian Kotek tacked this problem
> > > > using the Bridge Pattern.
> > > > Brian, if you read this can you give more details on this. I'd be
> > > > interested if you have worked on this problem.
> > > >
> > > > Anyone else with ideas?
> > > >
> > > > Alan
> > > >
> > >
> >
> > > >
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CFCDev" 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/cfcdev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to