Thanks for the response,
I hope I am over-complicating things for sure.
The images are static resources at this point. The db names are dynamic
as a halfway step towards the eventual goal of allowing uploads by the
user (as you mention in the latter half of your e-mail). At this point
our release version will not support uploads though.
I do benefit from having the names in the DB in the sense that I can run
a loop over Entity objects pulled from the DB and then read the image
from there instead of writing static html tags for each image.
After messing around with your advice, I think I'm getting a better
sense to the issues I'm facing here. Allow me to explain.
I display these images in two places: an overview page that loops over a
custom component I have (this component has the [img ] tag), and in a
column in a grid of the Product entities on another page.
The custom component, ContentBubble, takes in a parameter called imgRef
that has set BindingConstants.CONTEXT and it writes out the tag as [img
src="${imgRef}" /].
Previously, I was able to see a placeholder hardcoded image on these
pages. In the TML page that declares the ContentBubble, the imgRef
parameter was set like so:
imgRef="layout/images/placeholder.gif"
Now when I modify this to include the dynamic name the images no longer
work:
imgRef="layout/images/${product.imageLink}"
where product.imageLink would resolve to placeholder.gif
Now that I've singled it down to this, I think my problem should be more
obvious and hopefully simpler.
Thanks for your patience,
Rich
On 12/14/2010 03:42 PM, Kalle Korhonen wrote:
You are way over-complicating things. If these are static resources
(your webapp/ implies that but storing the names in the db implies the
opposite), you can just refer to them by
/layout/images/product/<filename> (possibly add a context path). If
they are not static resources, e.g. users of your application upload
these images, you have to store them outside of the webapplication
context path, something like /var/<myapplication>/images/ for example.
Then you create a link to the resource and return a stream response to
a particular image with something like:
public Link getUploadedProductImage() {
return resources.createEventLink("productimage");
}
public StreamResponse onUploadedProductImage() throws
FileNotFoundException, IOException {
return new
BufferedImageStreamResponse(ImageIO.read(productImageStorage.getProductImageInputStream(productId)));
}
Kalle
On Mon, Dec 13, 2010 at 1:32 PM, Rich M<rich...@moremagic.com> wrote:
Hi,
I'm having a hard time figuring out how to dynamically display some images I
have in a sub-path of my webapp/ folder in my Tapestry application
(1.5.0.5).
I have db entities that store the names of files in a folder in
webapp/layout/images/products/, and in a TML page using a grid, I want to be
able to display these images.
The only way I was able to get an image to display was to provide a path
like: /app/assets/ctx/1.0/layout/images/products/${prod.imageLink}
That gave me problems with my Application filter/dispatcher, however, as it
seemed to regard this is a page access outside the scope of the user-session
context and log out the user.
I'm pretty sure I shouldn't be hardcoding that reference to the asset from a
url anyway, how can I have it load the image through tapestry like all the
other images in the site, like the ones I load through CSS that do not break
the application filter/dispatcher?
I hope I was clear enough as to what my problem is.
Thanks,
Rich
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org