Hi David,
this is not possible as an embedded element, since you can't embed
the actual content of a PNG image inside HTML text. You'll first have
to write an embedded element that outputs the <img src="..." /> tag.
After that you'll have to write an element that handles the response
to src="..." attribute. I encourage you to not hard-code the URL of
the src attribute, but detect the URL of the image URL:
getSite().resolveId("PngImageElement", getElementInfo()).getUrl()
The very above looks it up relative to the current element, you can
also look it up absolutely, like this:
getSite().resolveId(".Pub.Binary.PngImageElement").getUrl()
The relative one is better though. Just a small note (which you maybe
don't know), dots separate the sub-sites, and '^' goes one level up.
So consider your current element's ID is '.Pub.Portal.PngImage' and
you want the refer relatively to the image element, you'll write
'^^Binary.PngImageElement'.
That image element is very servlet-like. If your content-type is
fixed (ie. always png), set is during the declaration of your element
(contenttype attribute). If it's dynamic, set the contenttype
attribute to "" (empty), and use setContentType("image/png") inside
the element implementation. After doing that, you can obtain the
binary OutputStream with getOutputStream() and stream anything
through it.
Hope this helps,
Geert
On 05 May 2006, at 19:10, David Herbert wrote:
Hello,
I wonder whether there is provision in RIFE for an element which
writes out content as a binary stream e.g. a PNG image representing
a graph or chart created with a charting package? I can create a
page with an embedded element which creates the chart, I'm just
stuck as to how to output the PNG data using RIFE functionality. I
know how to do this using HttpServletResponse e.g:
BufferedImage image = ImageIO.read( url );
response.setContentType( "png" );
ImageIO.write( image, "png", out );
However I don't think this is right here - anyone point me in the
right direction?
Thanks,
David Herbert.
_______________________________________________
Rife-users mailing list
[email protected]
http://lists.uwyn.com/mailman/listinfo/rife-users
--
Geert Bevin Uwyn bvba GTalk: [EMAIL PROTECTED]
"Use what you need" Avenue de Scailmont 34 Skype: gbevin
http://www.uwyn.com 7170 Manage, Belgium AIM: geertbevin
gbevin at uwyn dot com Tel: +32 64 84 80 03 Mobile: +32 477 302 599
PGP Fingerprint : 4E21 6399 CD9E A384 6619 719A C8F4 D40D 309F D6A9
Public PGP key : available at servers pgp.mit.edu, wwwkeys.pgp.net
_______________________________________________
Rife-users mailing list
[email protected]
http://lists.uwyn.com/mailman/listinfo/rife-users