You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by José Paumard <Jo...@orange.fr> on 2009/03/02 20:00:12 UTC

Behavior of Resource.forFile()

Hello all,

I need to check the existence of an image in a  folder.

Here is what I first did  :

@Inject
@Path("context:images/folder")
private Asset imageFolder ;

public boolean isExists() {
    Resource image = imageFolder.getResource().forFile(getImageName()) ;
    return image.exists() ;
}

What I expect is image to point to context:images/folder/myimage.jpg, 
but it does not and this method always return false. In fact the 
"folder" part of the path is not present in the image resource, which is 
: context:images/myimage.jpg.

Now I'm not sure if this is a bug or if I'm wrong on the way forFile() 
is supposed to work. So any hint would be appreciated.

Thank you,

José

PS : btw there is a workaround, I'm not too happy with it :
String imageFilename = imageFolder.getResource().toURL().getFile() + 
getImageName() ;
File imageFile = new File(imageFilename) ;
return imageFile.exists() && imageFile.canRead() ;




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