Displaying Images from local Filesystem in Grid

Hi,

I tried to display images in one Column of my Grid by using the ImageRenderer. The image files I want to display are outside of the application anywhere on my file system. So I tried the following:

getColumn(myDTO.PICTURE).setRenderer(new ImageRenderer(), new Converter<Resource, String>() {

@Override public String convertToModel(final Resource resource, final Class<? extends String> aClass, final Locale locale) throws ConversionException
{ return “not needed”; }

@Override public Resource convertToPresentation(final String absolutePath, final Class<? extends Resource> aClass, final Locale locale) throws ConversionException
{
return new FileResource(new File(absolutePath))
; }

@Override public Class getModelType()
{ return String.class; }

@Override public Class getPresentationType()
{ return Resource.class; }

});

But this is producing the following IllegalArgumentException: java.lang.IllegalArgumentException: ImageRenderer only supports ExternalResource and ThemeResource (FileResourcegiven )

So my question is: Will the FileResource be supported by ImageRenderer in future releases? Or is there another way of displaying images in my grid from anywhere on the local file system? Thank You!

Greetings,

Marco

Similar problem. Is there really no solution to this?

I’m trying to display dynamically generated images in a Grid. External and Theme resources are not something I can use.

This is covered by https://dev.vaadin.com/ticket/18555 which seems to have an old, incomplete patch waiting for someone to finish it.

As a workaround, you can probably make your own “file serving servlet” and decide your own URL scheme and use ExternalResource. Just make sure you don’t accidentally publish all files on the disk…

Thank you! This patch is exactly what I needed. I hope it makes it into the main streamline soon.