To follow up,

while the link/change I mentioned that got images to display using the app/assets/ctx/1.0/<...> was working using mvn jetty:run on my development machine, deploying as a WAR seems to break these links in a production environment.

So I'm back to square one it seems, is there no simple way to do this? If so I'm guessing I'll have to manually load the files, into an Asset or something along those lines?

It doesn't really matter to me if what I have to do is hard or easy, I just need to know what it is!

As a follow up, I am able to use the File class from java.io to load the image files from the filesystem, so might that be a starting point for me to get my desired results?

I also looked at this page http://tapestry.1045711.n5.nabble.com/T5-Auto-Generated-Picture-Gallery-Intranet-td3298328.html but the images won't display. I thinking because these files aren't being served, my local machine can resolve the "file:///<..>" urls to the image files, but they won't actually display in the page. I'm thinking this might not be my best solution for a production environment.

Thanks,
Rich

On 12/14/2010 11:03 AM, Rich M wrote:
Hi,

Yea, I wasn't expecting TML shorthand, rather some way to load the proper information in the page class.

I couldn't really see how the ContextAssetFactory would be useful. I was under the impression internal services shouldn't be used, in fact trying to Inject it gives an error.

In terms of loading the file as a Resource (required parameter for the createAsset method), I've had trouble with that as well.

I have a database entity that stores a reference to the image file (this is the same entity in the grid I mentioned before). When creating or editing this entity, I tried making a validation check that the file actually exists in the system.

Resource resc = new ContextResource(cimpl, "src/main/webapp/layout/images/products/"+link);

    if(!resc.exists()){

debug("\nImageLink is to a non-existant file! " + resc.getPath() + " get file: " + resc.getFile() + " to url: " + resc.toURL() + "\n\n");

_form.recordError(imageLink ,messages.get("image-link-non-existant"));

            return;

    }


Even though the files I tried definitely exist (I know because if I remove the validation I can get some images to show in pages loading the entity), the condition on !resc.exists() always fails.

I have code elsewhere that uses

Resource resc = new ContextResource(cimpl, "src/main/webapp/layout/images/products/"+link);

to load .xml files with the beginning to the path "src/main/webapp/.." that works, so I'm having a hard time understanding why it fails. The other implementation is in components.reports package, while this one is in pages.admin package. That wouldn't make a difference on the path needed for the ContextResource, would it?

I actually got passed the filter issue by doing this:

instead of TML having <img src="/app/assets/ctx/1.0/layout/images/products/${prod.imageLink}" />

I moved the src text to the page class

<img src="${getImageThumb()}" />

maybe that wasn't even the issue.. So it seems I am able to load the images alright then.

I could still use some help with the Resource checking. Is that the best idea for validating the existence of a file in the context (assuming I get it to work properly)?

Thanks,
Rich

On 12/14/2010 06:52 AM, LLTYK wrote:
I don't think there's a tml shorthand. You'd use ContextAssetFactory in your
java code:
http://tapestry-users.832.n2.nabble.com/T5-How-to-load-image-Asset-from-filesystem-td2454924.html#a2455270

But that would generate the same /app/assets links, just not hardcoded. This filter issue remains a mystery, tell us more about it. What do your css urls
look like?

   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

Reply via email to