views:

56

answers:

1

Hello all,

We have an app that has the following characteristics-

a) Flex front-end.
b) Spring, BlazeDS and tomcat back-end
c) Flex UI communicates with the back-end server using AMF/xmlrpc
d) Mate framework is used for Flex front-end

I have a requirement to generate reports on the flex UI and be able to export these reports in PDF and MS-Excel formats.

Flex UI > Report > Export As PDF > AMF call to back-end > AMF response to front-end for downloading a pdf file (dynamically generated on server).

Typically using struts/Tomcat serving dynamic html content, I can easily achieve this as an action class that streams PDF file content as a response (setting proper mime-type etc.,) This is easily handled by the browser which brings up the "Save file" dialog box.

Any ideas if this can be made to work with Flex AMF/BlazeDS request/response? Or is this possible only by using HTTPService on Flex side as given in this URL-

http://forums.adobe.com/thread/582595?decorator=print&displayFullThread=true

Sending the byte[] itself as the AMF response would typically cause the entire byte[] to be stored in the memory of the Flex UI (browser) before it can be prompted to be saved on client machine right? Also in this approach the entire document content needs to be fit inside a byte[] before it can be returned.

Can anyone please share their experience on what's the best design for handling file streaming to Flex UI from a BlazeDS/Spring backend?

Thanks!
-Keshav

A: 

Have the call return a URL to the generated PDF and open that in a new browser window. Basically hand off the process of downloading it to the browser.

Or use the URL for passing into a FileReference object and use that for the downloading.

Gregor Kiddie