views:

509

answers:

1

I have a grails application that will be rendering an html page into a pdf file and I have a flex application sitting on a server that is going to accept REST parameters and construct a graph based on the parameters (which will be formatted in JSON). What I want to do is make a call to the flex app with my parameters and have the flex app create the graph, render a JPEG of the graph, then send an image back to grails. In other words, I want to put an HTML img src="http://flex-app-location/graphing-tool.swf?param=1&param=2&param=3"/ that will render the image directly to the page so that my PDF Plugin in grails will render it into the PDF.

I know how to render the image in Flex but I don't know how to push this image back over HTTP so that it can be rendered as image data. Any suggestions?

A: 

Hi,

Do you know there is a Flex Plugin for Grails? http://grails.org/Flex+Plugin It allows you to expose your grails services as Flex remoting destination.

So I guess I would do something like :

  • Construct bitmap in Flex
  • Encode it into JPEG (See JPEGEncoder class).
  • Send this ByteArray to a remote grails service that accepts a byte[] parameter (Flex plugin use BlazeDS so your AS3 ByteArray object will be converted to an array of Java byte)

PS: Encoding can be done on the server too especially if your image size is really big and you don't care about sending a lot of data across the network

PeZ