You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by "OSullivan, Michael" <Mi...@analog.com> on 2008/09/29 14:58:11 UTC
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: user-unsubscribe@turbine.apache.org
For additional commands, e-mail: user-help@turbine.apache.org
Re: communication between turbine servlets and JFreeChart
Posted by Vick V Lagad <vi...@gmail.com>.
Michael,
Did this resolve your issue?
Vick
On Mon, Sep 29, 2008 at 9:36 AM, Tony Oslund <To...@prepare-enrich.com>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:Michael.OSullivan@analog.com]
> Sent: Monday, September 29, 2008 7:58 AM
> To: user@turbine.apache.org
> 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: user-unsubscribe@turbine.apache.org
> For additional commands, e-mail: user-help@turbine.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@turbine.apache.org
> For additional commands, e-mail: user-help@turbine.apache.org
>
>
RE: communication between turbine servlets and JFreeChart
Posted by Tony Oslund <To...@prepare-enrich.com>.
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:Michael.OSullivan@analog.com]
Sent: Monday, September 29, 2008 7:58 AM
To: user@turbine.apache.org
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: user-unsubscribe@turbine.apache.org
For additional commands, e-mail: user-help@turbine.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@turbine.apache.org
For additional commands, e-mail: user-help@turbine.apache.org