You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Nathan Quirynen <na...@pensionarchitects.be> on 2014/12/08 17:32:18 UTC

Check if asset exists

Hey,

When loading an asset with AssetSource.getContextAsset(path, locale) it
will throw a RuntimeException if the file doesn't exist. But what if I
want to load the asset only if it exists?
Is there a method anywhere that can check if an asset exists? I could
wrap it with a try catch, but that doesn't seem a clean solution here.

Thanks,
Nathan


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


Re: Check if asset exists

Posted by Nathan Quirynen <na...@pensionarchitects.be>.
I found a solution for my case:

AssetSource.resourceForPath("context:"+path).exists()

On 08/12/14 17:32, Nathan Quirynen wrote:
> Hey,
>
> When loading an asset with AssetSource.getContextAsset(path, locale) it
> will throw a RuntimeException if the file doesn't exist. But what if I
> want to load the asset only if it exists?
> Is there a method anywhere that can check if an asset exists? I could
> wrap it with a try catch, but that doesn't seem a clean solution here.
>
> Thanks,
> Nathan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


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