I would have your listener create each object, place them in an array,
and pass the array to your business model. You *could* do validation in
the listener, but it may be a better idea to do it in your model layer.

You don't need to make it overly complex, nor would I worry about too
much "business" logic in your listener. Your listener's job is to take
an ugly mess of form fields and turn it into a nice array of objects.
That is fine in my book (although I might use a filter instead of a
listener). The goal here is to make it easy to interact with the
business model, say in the future when you write a flash front end, and
it's no longer html form fields coming in, but arguments to a webservice
call. The webservice operation would perform similar steps as the
mach-ii listener, but the important point is that the model layer has no
concern with how the data got there (Mr. Model says "all I want is an
array of Foo damnit... don't bother me with anything else!).

-Dave

>>> [EMAIL PROTECTED] 1/18/2005 11:46:11 AM >>>
I've been making my listeners pretty dumb and putting all the business
logic
into the objectService.cfc.  Seemed like a good idea at the time, but
now
that I think about it, it does seem like I'm creating a pretty
pointless
layer of abstraction.

Going back to the validation though...

As I mentioned, I've been using the objectBean.cfc /
validateFormObject.cfc
approach as suggested in the machii development guide.  Could I then
create
a objectBeans.cfc that is an array of objectBean instances with its
own
validate method?  
The validateFormObject.cfc would then call the objectBeans.cfc
validate
method which would process the validate method for each instance of
the
objectBean.  Then the errors would trickle up somehow... Or have I gone
off
the deep end?

Thanks for the help and also thanks for making the mach-ii.info code
freely
available.  It's still an invaluable learning resource for me.

Sam

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf
Of Phil Cruz
Sent: Tuesday, January 18, 2005 12:13 PM
To: [email protected] 
Subject: Re: [CFCDev] Multiple object instances from a single form

If you are implementing the service layer because that is how you think
you
need to achieve this functionality I would say that is somewhat off
base.

Patterns have certain "driving forces" that justify their
implementation.
For example, if you wanted to support multiple database platforms that
would
"drive" you to implement an Abstract Factory pattern.  If you want to
provide a "API" of your application such that it can support multiple
client
types (HTML/Flash/Mobile
phone/...) then you may want to implement the service layer.

You may have other reasons to implement a service layer but doing so
to
create multiple object instances and persist them doesn't sound like a
valid
one.

As for validation code, you would typically have some validation code
in the
BO.  If you're processing multiple BO you may have other validation
code
(that catches validation errors from each BO).  The code that creates
the
array of objects could be in the Listener.

Does that help?

-Phil


On Tue, 18 Jan 2005 04:03:14 -0400, Sam Clement <[EMAIL PROTECTED]>
wrote:
> I'm looking to create a form that allows a user to cut and paste from

> an excel file that will then create multiple instances of an object 
> and then add them to the persistence layer.  Am I way off base trying

> to implement this from the service layer?
> 
> Normally I'd use the bean.cfc, validateFormObject.cfc model but by 
> creating multiple object instances from a single form I'm having 
> difficulty figuring out where I should be putting the validation code

> and the code that creates the array of objects (to be persisted).  I

> was thinking of rolling the creation of the array of objects and 
> validation into one function/method within the service layer.  Does 
> that make sense in the context of what I'm trying to do?
> 
> Any insight appreciated.
> 
> Cheers,
> 
> Sam
> ________________________________
> 
> Sam Clement
> ABOVE Studios
> Boutique Design Solutions
> 
> <http://www.abovestudios.com/>
> 32 Clifford St - Belmont
> Trinidad + Tobago - West Indies
> T: (868) 621 5159 W: abovestudios.com
> <http://www.abovestudios.com/>
> 
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email to 
> [EMAIL PROTECTED] with the words 'unsubscribe cfcdev'
> in the message of the email.
> 
> CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool,

> Corporation (www.mindtool.com).
> 
> An archive of the CFCDev list is available at 
> www.mail-archive.com/[email protected] 
>
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[EMAIL PROTECTED] with the words 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool,
Corporation (www.mindtool.com).

An archive of the CFCDev list is available at
www.mail-archive.com/[email protected] 

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at 
www.mail-archive.com/[email protected]

Reply via email to