A
WebAppResource represents a file that is local to the web application. This class is primarily used
by the resource handler for rendering web assets (CSS/IMG/JavaScript) by returning a direct access URL instead of
returning a JSF resource URL.
Consider the following code layout:
webapp/
|
|-resources/
|
|-bootstrap/
|
|-css/
|
|- bootstrap.min.css
Using standard JSF resource handling, the above css file will get rendered as the following URL:
/javax.faces.resource/css/bootstrap.min.css.xhtml?ln=bootstrap
This kind of a URL causes issues when the CSS file has
url(..) references in it as they do not get
resolved properly.
The WebAppResource object tries to resolve the target URL to a webapp local location and returns that
when getRequestPath() is invoked. So the same above code will end up in a url that looks like the following:
/resources/bootstrap/css/bootstrap.min.css