JSF resource versioning

If I do like this resources/js/1_0_0/mainscript.js

It does not work. It says RESOURCE_NOT_FOUND

This will work if you specify js as library name.

<h:outputScript library="js" name="mainscript.js" />

However, this is not the proper usage of a resource library. Rather introduce one.


Then you can specify it as follows:

<h:outputScript library="default" name="js/mainscript.js" />

They did not have any versioning in there but how did it append v=2.2.1 in the head

It’s done by PrimeResource which kicks in on resource requests with ln=primefaces parameter. Its getRequestPath() has the following implementation:

public String getRequestPath() {
    return super.getRequestPath() + "&amp;v=" + Constants.VERSION;

Where Constants is the PrimeFaces specific constants file which is updated with every PF version.

Leave a Comment