PAGE CLASS

inject component resources so that you can create an action link
    @Inject 
    private ComponentResources mComponentResources; 

when the path is requested by the template, create and return an action link
        public Link getImagePath() {
                return mComponentResources.createActionLink("image", false,
mItem.getID());
        }

handle this action link
        public Object onImage(long pID) { 
"StreamResponseBuilder" is a class that I have implemented, it basically
figures out what image to served based on
the id passed in the context and then gets an "InputStream" for the image
file on disk and creates and returns a "StreamResponse", so essentially you
want this action handler to return a "StreamResponse" of the image you want
to display.
                return StreamResponseBuilder.getItemImage(pID);
        }

PAGE TEMPLATE

${imagePath} 

Hope this helps
Regards,
Daniel



Peter Kanze wrote:
> 
> Hello
> 
> I want to load images from the filesystem, like for example
> D:/category/1/products/55/thumb.jpg
> 
> So the file path is dynamic and is based on the categoryId and the
> productId.
> 
> How can I load such an image into my webpage using a Tapestry Asset?
> This looks like a common usecase to me, but I couldn't find any info about
> it.
> 
> Has somebody already done this? And could he/she show me some code
> examples?
> Any help is welcome!
> 
> Thanks,
> Peter
> 
> 

-- 
View this message in context: 
http://www.nabble.com/T5%3A-How-to-load-image-Asset-from-filesystem--tp22433419p22471474.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to