Seems like InputStream is getting converted to string.

Response header from browser:
X-Cocoon-Version: 2.2.0
Accept-Ranges: bytes
Content-Type: image/png
Content-Length: 36
Server: Jetty(6.1.7)

200 OK

The Content-Length: 36 is same as output of 
System.out.println(is.toString().length()) - where "is" is InputStream.
I also get a warning at console when starting jetty.
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!

Not sure if this warning is relevant.

Has anyone encountered similar issue or has a suggestion?

--- On Fri, 8/7/09, sh kh <[email protected]> wrote:

From: sh kh <[email protected]>
Subject: Re: Trouble with Dynamic Chart
To: [email protected]
Date: Friday, August 7, 2009, 11:11 AM

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 <[email protected]> wrote:

From: warrell
 harries <[email protected]>
Subject: Re: Trouble with
 Dynamic Chart
To: [email protected]
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 <[email protected]>


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