Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

In JSF page templates I use this code to include a CSS resource:

<h:outputStylesheet library="css" name="mystyles.css"  />

The usual way to implement CSS cache busting would be to add a version parameter, like v=123, however this is not supported in outputStyleSheet:

<h:outputStylesheet library="css" name="mystyles.css?v=123"  />

will cause a JSF1064 warning and the CSS will not be found.

share|improve this question

1 Answer 1

up vote 6 down vote accepted

That's not possible without overridding the StylesheetRenderer (assuming you're on Mojarra). It does indeed not take the query string into account. However, as a (temporary) workaround it's good to know that it is valid to include the CSS using CSS' own @import rule inside <h:outputStyleSheet>.

<h:outputStylesheet target="head">
    @import url('css/mystyles.css?v=123')
</h:outputStylesheet>

You might want to post an enhancement request to the Mojarra boys to take this into account in future releases.

share|improve this answer
    
And how does it work for <h:graphicImage />? –  banterCZ Feb 28 '13 at 11:26
    
@banter: better use resource library versioning. See also bottom of this answer: stackoverflow.com/questions/11988415/… –  BalusC Feb 28 '13 at 11:36
    
Thanks, but I would like to avoid to rename directories. From JSP, I am used to define scripts version via maven version propagated to request. So it does not look like that there is a simple solution in JSF. –  banterCZ Feb 28 '13 at 12:06
1  
@banter: Create a custom resource handler then. –  BalusC Feb 28 '13 at 12:07
    
What about not to use 'h' tags and write just html? –  banterCZ Feb 28 '13 at 12:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.