Just because we’re trying to make that line of code shorter, you could do this too:

 

<cfset CreateObject("component","CollectionBeanMaker").init(FORM).MakeBean(User).save() />

 

No need to return the user, it’s an object and is populated byref ;)

 

But yea, this functionality doesn’t belong in reactor. 

 

Doug

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jared Rypka-Hauer
Sent: Tuesday, February 28, 2006 8:27 PM
To: [email protected]
Subject: Re: SPAM-LOW: RE: [Reactor For CF] Cutting out Repetive setXXX(FORM.XXX)

 

Dan...

 

It's all about delegation, dude...

 

Reactor's job is to get/save data in terms of interacting with databases. It may be a good idea to have an object like the one from MG to handle what you want, but the clear lines of responsibility with a model that makes things make sense. :) So Reactor gets you beans... where the data that goes into the beans comes from isn't Reactor's responsibility. It doesn't relate to DAO business, it relates to UI/model business... which is what your controllers are for in MG/M2. Using something like that object, or its equivalent in a framework controller, is your best course of action.

 

Incidentally, you could further reduce your code below a little bit:

 

<cfset User = CreateObject("component","CollectionBeanMaker").init(FORM).MakeBean(User).save() />

 

Since the createObject().init() call returns the CollectionBeanMaker and the .makeBean() call returns the User bean populated with data from the form scope, you can simply tack your save() call on the end of it. The way the objects work, since your User exists before your CollectionBeanMaker, once the CBN is done calling the setters the data will be set up in User because objects are passed byRef. However, since makeBean() DOES return the populated object, it's available at the end of the method chain to tack save() onto.

 

Laterz,

J

 

 

------------------------------------------------

Jared C. Rypka-Hauer

Continuum Media Group LLC

http://www.web-relevant.com

Member, Team Macromedia - ColdFusion

 

"That which does not kill me makes me stranger." - Yonah Schmeidler

 

On Feb 28, 2006, at 7:13 PM, Daniel Short wrote:

 

Thanks for the response Doug. That's roughly what I was going to be doing

(though I'm sure not quite as elegant...). So in my page I'd do this?

 

<cfset User = CreateObject("component",

"CollectionBeanMaker").init(FORM).MakeBean(User) />

<cfset User.Save() />

 

Is that right? This seems like something that would fit nicely in one of the

Reactor base files to cut out the middle man, since it directly relates to

DAO business. If you still think it's best left to an outside component, I

won't pitch a fit :).

 

Dan

 

 

 

 

 

-- Reactor for ColdFusion Mailing List -- [email protected]

 

 

 

-- Reactor for ColdFusion Mailing List -- [email protected] -- Archives at http://www.mail-archive.com/reactor%40doughughes.net/

Reply via email to