0

I have a java ee application running under glassfish 4, JSF 2.2 on windows7 x64. And I have noticed that all my resources are served with an extra .xhtml extension.

for example:

/javax.faces.resource/bootstrap/css/bootstrap-theme.min.css.xhtml

instead of

/javax.faces.resource/bootstrap/css/bootstrap-theme.min.css

Is there any way of removing the extra .xhtml extension?

The reason I want to do this is to avoid having to modify the paths in the all the external js and css libraries that I use.

1 Answers1

1

You should take a look at OmniFaces UnmappedResourceHandler

This ResourceHandler implementation allows the developer to map JSF resources on an URL pattern of /javax.faces.resource/* (basically, the value of the ResourceHandler.RESOURCE_IDENTIFIER constant) without the need for an additional FacesServlet prefix or suffix URL pattern in the default produced resource URLs, such as /javax.faces.resource/faces/css/style.css or /javax.faces.resource/css/style.css.xhtml. This resource handler will produce unmapped URLs like /javax.faces.resource/css/style.css. This has the major advantage that the developer don't need the #{resource} EL expression anymore in order to properly reference relative URLs to images in CSS files.

Also , take a look at this Prevent suffix from being added to resources when page loads


You also can point from one js to other js/css with the following approach:

Lets say you want to populate the css and js properties of some js object:

css:    $(document).find("link[href*='my-third-party-plugin']").attr("href"),
js:     $(document).find("script[src*='my-third-party-plugin']").attr("src")
Community
  • 1
  • 1
Daniel
  • 36,833
  • 10
  • 119
  • 200
  • There is a lot of image and font referencing from .css and .js files. Problem is because of the extra extension they cannot be found. –  Mar 09 '14 at 11:52
  • The only small change was: Faces Servlet instead of facesServlet in web.xml –  Mar 09 '14 at 12:07