Re: communication between turbine servlets and JFreeChart
"Vick V Lagad" <[email protected]>
| Newsgroups | gmane.comp.jakarta.turbine.user |
|---|---|
| Message-ID | <[email protected]> |
Michael, Did this resolve your issue? Vick On Mon, Sep 29, 2008 at 9:36 AM, Tony Oslund <[email protected]>wrote: > > Try the following instead. > > #set ($mysrc = $link.setPage("mrtg,Image.vm")) > <img src="$mysrc" border="0"/> > > > - or - > > Notice the single quotes. > > <img src="$link.setPage('mrtg,Image.vm')" border="0"/> > > Tony > > > -----Original Message----- > From: OSullivan, Michael [mailto:[email protected]] > Sent: Monday, September 29, 2008 7:58 AM > To: [email protected] > Subject: communication between turbine servlets and JFreeChart > > Hi > > I am trying to get my turbine app to display a dynamic chart using = > Jfreechart and Velocity templating but to no avail. I've been using the > = example below which was sent via one of the forum threads. I've > created = a Java Screen class (i.e not an action class) exactly the same > as in the = attached code and I have included the following image tag in > my velocity = template but to no avail.=20 > > <img src="$link.setPage("mrtg,Image.vm")" border="0"/> > > To start I would just like to get this example working and then try and > = add tooltips and url drill down to the image. Should this be possible > = using the method outlined below. Any help would be greatly > appreciated. > > Thanks > Regards, Mike > > > ######################################################################## > #= > ######################################################### > > > Hi, > > here is a simple example: > > package de.byteaction.modules.screens.mrtg; > > > import org.apache.turbine.modules.screens.RawScreen; > > import org.apache.turbine.util.RunData; > > import org.jfree.chart.ChartUtilities; > import org.jfree.chart.JFreeChart; > > import java.io.OutputStream; > > /** > * @author buddy > */ > public class Image extends RawScreen > { > /* (non-Javadoc) > * @see = > org.apache.turbine.modules.screens.RawScreen#getContentType(org.apache.t > u= > rbine.util.RunData) > */ > protected String getContentType(RunData data) > { > return "image/jpeg"; > } > > /* (non-Javadoc) > * @see = > org.apache.turbine.modules.screens.RawScreen#doOutput(org.apache.turbine > .= > util.RunData) > */ > protected void doOutput(RunData data) throws Exception > { > JFreeChart chart =3D (JFreeChart) = > data.getSession().getAttribute("chart"); > OutputStream out =3D data.getResponse().getOutputStream(); > > ChartUtilities.writeChartAsJPEG(out, chart, 800, 400); > out.flush(); > } > } > > I have build the chart inside my action and put it into the users = > Session. You could do that using > data.getUser().setTemp("image"),JFreeChart) also. > Then I have setup the screen like this. Now I can reference the screen = > in my image tags > > <img src=3D"$link.setPage("mrtg,Image.vm")" border=3D"0"/> > > kind regards=20 > > J=FCrgen Hoffmann > > > --------------------------------------------------------------------- > 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] > >