Re: How to set cfset session variable to be called in a cfc?
Faye, The way you're handling the export has a number of issues. If you don't mind, I'll suggest a somewhat different flow to the logic. I definitely would not use the session scope here. It's just not necessary. But first - have you actually tested your .cfm file by placing some data into the session scope, then seeing what comes out? Completely in isolation from Flex? I've never seen an attempt to create a spreadsheet this way, by simply outputting some data and giving it a spreadsheet content type: WriteOutput(session.exportData); I'm not certain, but I don't think it will work. In your .cfm file, set session.data to something and see what you get. I'm guessing it won't work, but I could be wrong. I've created many spreadsheets from ColdFusion, and they always require a good bit of manipulation, or the use of the tags and functions in later versions. I don't think you can just dump the data in that way, although perhaps since it's a struct, it'll work. I don't know. But there are certainly lots of ways in CF to create spreadsheets from data structures cleanly, and I'd suggest using one. So make sure you can actually create a spreadsheet, with valid data, before you go further. Here's how I would suggest you make things flow:(Again, this is with the assumption that the methods need no arguments for filtering.) - In your button handler, do not make a remote object call. Instead, go ahead and make your URLRequest to the .cfm file. - In your .cfm file, create an instance of your gateway and retrieve the data. - Then create an instance of your export cfc, call its method and pass in the data retrieved in the previous step. - Now do whatever's necessary to actually create everything as a spreadsheet. It could be simpler - create a method in a cfc called exportCustomerData which wraps the calls to the gateway and to the export function. So the problem should have nothing to do with Flex. Just make a URLRequest to a .cfm file - with parameters, if necessary - then handle all the processing there. You can do all your testing without Flex being involved, by calling the page directly in a browser. Mainly, make certain you can create the spreadsheet properly from CF. That's the key. If none of this makes sense, or if you need more help, let me know a couple of things: - what version of CF you are using, and - whether you've tested creating the spreadsheet in a .cfm file that way -- 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:340587 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: How to set cfset session variable to be called in a cfc?
>Faye, > > > >> >> I am trying to export the data which is an arrayCollection in Flex to >> Excel. I followed this article, >> http://viconflex.blogspot.com/2007/02/export-data-from-flex-app-using.html, >> and got all the components working. Now the last step is to make the data >> (arrayCollection) available in #arguments.data#, I guess. >> > >I'll need a little more explanation. Your original example was a ColdFusion >query. Now you say it's data coming from Flex. > >Is it being created from scratch in Flex? Didn't it originate as server-side >data? > >ColdFusion is just Java under the hood, and you'll find you'll use many of >the same patterns. > >If you can walk us through the process - basically, how did Flex get the >data, how was it manipulated, and such - what it's returning - we can >probably help. It would also help to know what's supposed to happen with the >spreadsheet. Is it to be displayed, just saved, or what? > >As much detail as you can provide on the steps in the process, please. > > >-- >Thanks, > >Tom > >Tom McNeer >MediumCool >http://www.mediumcool.com >1735 Johnson Road NE >Atlanta, GA 30306 >404.589.0560 Hi Tom, Let me give it one more try and be thorough. Please find all the files used below for this issue. The data is retrieved and Excel will open. The problem is, Excel is opened without any data. Code starts here == I will provide all my code here: Flex datagrid page: http://www.adobe.com/2006/mxml";> CustomerGateway.cfc select * from sav_customer Export.cfc getExcelFile.cfm WriteOutput(session.exportData); == Code ends here I need to know how to set session.exportData to the return from CustomerGateway return method. Do I need to create another function? Thank you very much for your time. Faye Larson Dallas ~| 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:340583 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: How to set cfset session variable to be called in a cfc?
>Faye, > > > >> >> I am trying to export the data which is an arrayCollection in Flex to >> Excel. I followed this article, >> http://viconflex.blogspot.com/2007/02/export-data-from-flex-app-using.html, >> and got all the components working. Now the last step is to make the data >> (arrayCollection) available in #arguments.data#, I guess. >> > >I'll need a little more explanation. Your original example was a ColdFusion >query. Now you say it's data coming from Flex. > >Is it being created from scratch in Flex? Didn't it originate as server-side >data? > >ColdFusion is just Java under the hood, and you'll find you'll use many of >the same patterns. > >If you can walk us through the process - basically, how did Flex get the >data, how was it manipulated, and such - what it's returning - we can >probably help. It would also help to know what's supposed to happen with the >spreadsheet. Is it to be displayed, just saved, or what? > >As much detail as you can provide on the steps in the process, please. > > >-- >Thanks, > >Tom > >Tom McNeer >MediumCool >http://www.mediumcool.com >1735 Johnson Road NE >Atlanta, GA 30306 >404.589.0560 The Flex datagrid page calls getAllAsStruct method in CustomerGateway.cfc which returns the array to Flex. private function buttonHandler():void { roWildcard.getAllAsStruct(); } The array is displayed here, Then, I am calling the exportToExcel method in Export.cfc which is supposed to get the array from the above. It will return a boolean. private function test():void{ exportManager.exportToExcel("" +"" + "The application has successfully exported this file" + "Eventually the actual data will be passed into this function" + ""); } If the above is true, I will then call a cfm file to spit it out. WriteOutput(session.exportData); We want to allow the user to choose where to save their data when it opens excel. My problem is, session.exportData is not tied in with the result from getAllAsStruct method in CustomerGateway.cfc It brings up Excel allowing to choose the location to save the file but the spreadsheet opens up with no data. I hope this helps to clear up some confusion. Thank you again. Faye Larson, Dallas ~| 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:340582 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: How to set cfset session variable to be called in a cfc?
Faye, On Fri, Jan 7, 2011 at 1:54 PM, Faye Larson wrote: > > I am trying to export the data which is an arrayCollection in Flex to > Excel. I followed this article, > http://viconflex.blogspot.com/2007/02/export-data-from-flex-app-using.html, > and got all the components working. Now the last step is to make the data > (arrayCollection) available in #arguments.data#, I guess. > I'll need a little more explanation. Your original example was a ColdFusion query. Now you say it's data coming from Flex. Is it being created from scratch in Flex? Didn't it originate as server-side data? ColdFusion is just Java under the hood, and you'll find you'll use many of the same patterns. If you can walk us through the process - basically, how did Flex get the data, how was it manipulated, and such - what it's returning - we can probably help. It would also help to know what's supposed to happen with the spreadsheet. Is it to be displayed, just saved, or what? As much detail as you can provide on the steps in the process, please. -- 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:340581 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: How to set cfset session variable to be called in a cfc?
I am trying to export the data which is an arrayCollection in Flex to Excel. I followed this article, http://viconflex.blogspot.com/2007/02/export-data-from-flex-app-using.html, and got all the components working. Now the last step is to make the data (arrayCollection) available in #arguments.data#, I guess. I am very new with ColdFusion. I have used Flex for awhile with Java as the backend. I appreciate it if you can help me to resolve this last step. Thank you very much. Faye Larson Dallas >Faye, > > > >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:340580 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: How to set cfset session variable to be called in a cfc?
Faye, On Fri, Jan 7, 2011 at 1:05 PM, Faye Larson 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
How to set cfset session variable to be called in a cfc?
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? How do I hook them up so that the getAllAsStruct array is available as #arguments.data#. Export.cfc CustomerGateway.cfc select * from sav_customer I am learning yet... Thank you for your help. Faye Larson ~| 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:340575 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm