I trying to create a Chart dinamically and place it in a html page , to do
so a create a ImageStreamResponse class that convert my Jfreechart instance
to a byteArrayInputStream
class ImageStreamResponse implements StreamResponse {
private JFreeChart jfreeChart ;
private String contentType ;
public ImageStreamResponse(final String contentType,
JFreeChart chart){
this.contentType = contentType ;
jfreeChart = chart ;
}
public String getContentType() {
return contentType;
}
public InputStream getStream() throws IOException {
BufferedImage image =
jfreeChart.createBufferedImage(600, 400);
ByteArrayOutputStream byteArray = new
ByteArrayOutputStream() ;
ChartUtilities.writeBufferedImageAsJPEG(byteArray,
image) ;
return new
ByteArrayInputStream(byteArray.toByteArray());
}
}
with an ActionLink
StreamResponse onActionFromViewChart(Object[] context) {
return viewChart.getGraph(context) ;
}
my viewChart.getGraph(Object[] context) method
public StreamResponse getGraph(Object[] context) {
JFreeChart jfreeChart = new BurnDownChartGenerator(context).getChart() ;
return jfreeChart != null ? new ImageStreamResponse("image/jpeg",
jfreeChart) : new TextStreamResponse("text/html","chart not available") ;
}
it generate a blank page with the image, but i need it to be a component so
i can place it (the image)within a fancy page.
--
View this message in context:
http://www.nabble.com/How-can-i-make-a-Stream-Response-a--Tapestry-Component-tf3989719.html#a11328870
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]