An alternative solution would be to create a Tapestry service
(instead of your graph servlet) and then use a ServiceLink
( or extend it to allow easier parameter passing) in order to link to your
service. You could then also create a custom image (service) component,
which would include your service as an image in the current page.
The process of changing your servlet to a service is nothing more
than copy-pasting and changing the way you get your parameters...
Jacob Lauem�ller wrote:
Hi all,
I'm currently using Tapestry to develop an application where I need to display
dynamically created charts of statistical data. I'm generating these graphs
using JFreeChart and my solution is to have a Tapestry page insert an Image
component and then bind this component to a ContextAsset which points to a
servlet that actually generates the bitmap.
The servlet needs to receive a few parameters defining the appearance of the
chart and I'm trying to accomplish this by building a URL to the servlet such
as
/chart?type=WaitingTime&start=2005.05.10_00:00:00&end=2005.05.25_00:00:00&granularity=AllDataPoints
and then using this as the path for the ContextResourceLocation passed to the
ContextAsset.
The problem is that when Tapestry renders the Image component, and thus
creates the <img src="xxx" ...> HTML tag, it ends up passing the src URL to
AbstractMarkupWriter.attribute(String name, String value) which uses the
safePrint() method to actually output the URL.
safePrint() replaces all characters for which HTML entities exists,
transforming the URL above to
/chart?type=WaitingTime&start=2005.05.10_00:00:00&end=2005.05.25_00:00:00&granularity=AllDataPoints
which obviously don't work -- the Servlet container (Tomcat 5.5.9 in this
case) doesn't reverse this transformation and -- in any case -- it seems
wrong to me to encode HTTP URLs using HTML entities.
I have tried to work around this issue by replacing the & characters in the
context URL with their hex equivalents, e.g. to use
/chart?type=WaitingTime%26start=2005.05.10_00:00:00%26end=2005.05.25_00:00:00%26granularity=AllDataPoints
in which case Tapestry no longer performs any conversions. Unfortunately,
Tomcat then no longer extracts Servlet parameters correctly, finding only one
parameter ('type' in the URL above).
What gives? Is this is a bug in Tapestry -- should it really render attributes
known to contain URLs such as src on <img> in this way? Or am I missing
something entirely?
TIA,
Jacob
---------------------------------------------------------------------
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]