Search code examples
jsf-2primefacesomnifacesunmappedresourcehandler

omnifaces UnmappedResourceHandler prevent primefaces dynamic image loading


i'm using Omnifaces (GREAT LIBRARY) in my project. It's a jsf 2 project with primefaces 4 library, running on JBoss 7.2. I've used the <p:graphicImage /> for loading an image from db. I've found the code on internet and it's working correctly.

The problem comes when i activated the UnmappedResourceHandler of omnifaces on my project. After activate, the handler is working ok, i can access to (other) image inside my resources by name from css. But this handler active, the loading of the image in the <p:graphicImage /> isn't working anymore. Debugging the code, i can only see 1 request for the content (without unmappedresourcehandler the request are 2).

Is there any workaround?

Thanks!


Solution

  • The problem has been fixed. The UnmappedResourceHandler incorrectly expected that ResourceHandler#createResource() would return null on those kind of resources, so that it could delegate the call to the wrapped resource handler. However, it didn't return null and ultimately an empty resource body was written to the response.

    It's fixed by checking if the request parameter ln equals "primefaces" and if the request parameter pfdrid is not null. The UnmappedResourceHandler will then delegate the call to the wrapped resource handler, which would be the PrimeResourceHandler.

    The changes are visible in commit 8abfb8a and are available as per today's 1.8 snapshot.