Faye,

On Fri, Jan 7, 2011 at 1:05 PM, Faye Larson <fz...@yahoo.com> wrote:

>
> With the following code from two cfc files, how do I pass the result from
> getAllAsStruct in CustomerGateway.cfc to exportToExcel, #arguments.data#, in
> Export.cfc?
>
> My environment is set up for using session variables. I need to cfset
> session.exportData somewhere so that it can be called?
>
>
Obviously, I don't know exactly what you're trying to do, but here's a
pretty good guess: the real point is to export some customer data as an
Excel file.

So you probably want another CFC (call it a "service" component), perhaps
called CustomerService.cfc.

In there you may have a method called "exportCustomerData," which might
possibly take some arguments, such as a Customer Type, a date range, or
other filtering mechanisms.

The CustomerService would call a method on CustomerGateway that retrieves
the query data. While the gateway *could* build the struct, you generally
want to leave that sort of work to another component, using the gateway
strictly for database interaction. So perhaps the gateway's method is just
"GetAll" (or whatever's appropriate, depending on whether you need to apply
filters in the query), and you build the struct (or array, or just leave it
as a query, depending on what you need), in the CustomerService.

Then the CustomerService calls the Export.cfc's method, and does whatever's
necessary - saving the spreadsheet, returning it to the browser, whatever.

Unless you have a reason to persist the query data from request to request,
you don't want or need to place it in the session scope.

So:


   1. Request calls method on CustomerService, optionally with filter data.
   2. CustomerService calls CustomerGateway to get data, optionally with
   filter.
   3. CustomerService manipulates data into what array/structure/etc. you
   want (this could even be done by some sort of utility cfc)
   4. CustomerService call Export.exportToExcel(data), passing in the data
   it has manipulated.
   5. CustomerService completes its action by returning the filename of the
   spreadsheet, or whatever's appropriate to your needs.


>From there on, it kinda depends on what you want to do with the spreadsheet.


-- 
Thanks,

Tom

Tom McNeer
MediumCool
http://www.mediumcool.com
1735 Johnson Road NE
Atlanta, GA 30306
404.589.0560


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:340579
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to