Thanks everyone for the responses so far, conceptually I think this is
coming together for me.
So, I'm glad the context path was not a good idea, it felt dirty from
the beginning. Avoiding that, there are two main options: use the
database to store/retrieve the images, or use a configured system folder
from where I can load/save files with Java IO.
Regardless of the option chosen there, the image file will be captured
as an InputStream and returned as a StreamResponse in some form to a
page/component.
As far as linking the StreamResponse to an HTML IMG tag, I believe I
understand the various options presented here.
LLTYK suggests using an EventLink. I was looking through my code and
found a Captcha implementation I have using a propertyExpression in the
TML on the src attribute of <IMG> to reference a getImageLink function
that returns ComponentResources.createActionLink("image",null). Then
there is an onImage() action handler method that returns a
StreamResponse. I understand this is ActionLink and not EventLink, but I
think the concept must be nearly identical.
Alternately, Thiago is suggesting that instead of using
ComponentResources to generate an ActionLink or EventLink, it may be
easier to create a seperate Page that handles returning just a
StreamResponse. In that case the EventLink can be replaced with a
PageLink and using an activation context the ID for the Image can be
passed to the Page so it can load the Image, build the StreamResponse,
and return it.
<30 minutes later> Okay, the PageLink works out, great! I can see the
biggest issue I was having was setting up the src attribute for IMG
correctly. I was stuck thinking it was either the URL to the context
path or the StreamResponse itself, rather than a link to an event or
page that returns the StreamResponse.
Thanks,
Rich
On 03/11/2011 08:08 AM, Thiago H. de Paula Figueiredo wrote:
On Fri, 11 Mar 2011 09:24:35 -0300, LLTYK <ll...@mailinator.com> wrote:
Nobody's mentioned createEventLink. That's where you get the image url,
create an event link pointing to the event handler that returns the
stream response.
I haven't mentioned it because my preferred approach is to create a
page just for returning StreamResponses. It's more reusable, as it can
be used to serve images for any page, while an event must be only used
inside a give page.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org