Thanks.  I did look at FINS and may eventually go that way (it needs both data 
and configuration in XML format, whereas this approach can work directly with 
JFreeChart configuration options and retrieving data directly from database, 
which is what I'm doing). 

However, I'm still puzzled why InputStream will not be rendered properly.  I 
also tried getting chart output as byte array instead of inputstream, and 
feeding that into map:read...that doesn't work either.  Perhaps I'm missing 
some configuration option in reader.....

Shailender

--- On Fri, 8/7/09, warrell harries <warrell.harr...@googlemail.com> wrote:

From: warrell harries <warrell.harr...@googlemail.com>
Subject: Re: Trouble with Dynamic Chart
To: users@cocoon.apache.org
Date: Friday, August 7, 2009, 4:32 AM

Have you looked at FINS? http://www.lucamorandini.it/fins/faq.html


2009/8/6 sh kh <techlogs...@yahoo.com>


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



      




      

Reply via email to