I'm following the Cocoon 2.2 tutorial. I created a dynamic chart with a java class implementing JFreeChart. I want to view the rendered chart in cocoon. I'm using flowscript and map:read, but no luck. I get a message saying the image contains errors when viewing src in Firefox ( I tested that the chart does show up fine if I write it to an external file...I could link to this file but would prefer not to write the chart to the disk).
I followed the approach from a previous post in the mailing list (http://article.gmane.org/gmane.text.xml.cocoon.user/57199) Here is the relevant method to return InputStream in MyClass public MyClass { public static InputStream getInputStream() { (Code to create chart omitted...) ByteArrayOutputStream out = new ByteArrayOutputStream(); JFreeChart chart = ChartFactory.createPieChart("Pie Chart", dataset, true, true, false); ChartUtilities.writeChartAsPNG(out, chart, 500, 300); InputStream is = new ByteArrayInputStream(out.toByteArray()); return is; } } Flowscript function demo() { var inputstream = MyClass.getInputStream(); cocoon.sendPage("screens/spring-bean", {"inputstream": inputstream}); } Sitemap: <map:pipeline> <map:match pattern="spring-bean"> <map:call function="demo"/> </map:match> </map:pipeline> <map:pipeline id="demo-internal" internal-only="true"> <!-- This pipeline is invoked by the above flowscript. --> <map:match pattern="screens/spring-bean"> <!-- doesn't make a difference if I remove type="image" from map:read --> <map:read type="image" src="module:flow-attr:inputstream" mime-type="image/png" /> </map:match> </map:pipeline> Any hints will be appreciated. Thanks. Shailender
