I've got little time so I did not try this,
I think this could work:
start with source from
org.apache.tapestry.corelib.components.ActionLink
change renderBody:
from
Link link = _resources.createActionLink(ACTION_EVENT, false,
contextArray);
writer.element("a", "href", link, "id", _clientId);
to:
Link link = _resources.createActionLink("graph", false,
contextArray);
writer.element("IMG", "src", link, "id", _clientId);
and then make your method for generating the graphs:
public StreamResponse onGraph(Object[] context) {
JFreeChart jfreeChart = new BurnDownChartGenerator(context).getChart() ;
return jfreeChart != null ? new ImageStreamResponse("image/jpeg",
jfreeChart) : new TextStreamResponse("text/html","chart not available") ;
}
On 6/28/07, Peter Schröder <[EMAIL PROTECTED]> wrote:
hi fidel,
there is already an example somewhere on the list. search for
streamresponse or chart.
kind regards,
peter
-----Ursprüngliche Nachricht-----
Von: Fidel Chavarria [mailto:[EMAIL PROTECTED]
Gesendet: Donnerstag, 28. Juni 2007 01:09
An: [email protected]
Betreff: How can i make a Tapestry Component of a Stream Response
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-Tapestry-Component-of-a-Stream-Response-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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]