Rewriting with JSF 2 h:outputStylesheet / h:outputScript failed

Splash Forums PrettyFaces Users Rewriting with JSF 2 h:outputStylesheet / h:outputScript failed

This topic contains 7 replies, has 3 voices, and was last updated by  Lincoln Baxter III 11 years, 3 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
  • #17792



    I’ve started to use PrettyFaces with JSF 2 and encountered a big problem. Maybe I’m doing something wrong. I want to avoid resource caching (JS, CSS files) and use in my web app JSF 2 tag h:outputStylesheet / h:outputScript with a special prepared URL:

    <h:outputScript library=”js” name=”xtime=#{applicationConfiguration.buildTime}/ip-jsftoolkit.js” target=”head”/>

    buildTime in the URL is generated if we build our war archive. The part with “xtime” should be removed by using of this configuration:

    <pretty-config xmlns=”″



    <rewrite match=”xtime=(d*)/(.+)” substitute=”$2″ redirect=”chain”/>


    Pattern and filter-mapping are correct, it’s not a problem. The problem is that HttpServletResponse.encodeURL() is not called if JSF tries to build the URL. I’ve not found this call in

    Resource resource = context.getApplication().getResourceHandler().createResource(name, library);

    Result: No rewriting is possible and we have many warnungs like

    13:05:54,312 WARNING [application] JSF1064: Ressource xtime=1287054180000/ip-jsftoolkit.js from library js can not be found or …..

    What is a possible solution for this issue?

    Thanks in advance!



    I think, I have to rewrite ScriptRenderer and StylesheetRenderer.



    Get rid of this xtime=… thing in the url and simply make sure, you’re resources are put in /resources/yourlibrary/1287054180000/ip-jsftoolkit.js when creating the war.

    jsf’s resource loading will automatically find the newest version and append a version=1287054180000 to the generated url which then gets resolved back and your resource is displayed. no need to do anything with prettyfaces here.



    Hi Dominic,

    Great idea! I know about this JSF 2 feature, but I did only think about URL-rewritng.

    Thank you a lot.




    No, it’s not what I wish me. I have now links like

    <link type=”text/css” rel=”stylesheet” href=”/icManagement/javax.faces.resource/ip-jsftoolkit.jsf?ln=js&v=20101014184544_0″>

    v=20101014184544_0 is not the part of URL. It’s in the query string. Such URLs are sometimes not cached at all (if e.g. tomcat with apache). I want to cache resources until the version is the same. This is my intention.


    Have you considered enabling this caching at the browser level?

    This way the unique filename will always be cached by the browser until the expiration date.



    In production mode, JSF adds appropriate cache headers.


    Good to know, thank you.

Viewing 8 posts - 1 through 8 (of 8 total)

The forum ‘PrettyFaces Users’ is closed to new topics and replies.

Comments are closed.