JSF resource versioning

旧城冷巷雨未停 提交于 2019-12-17 12:09:28

问题


I am trying to put versioning around the resources in an application.

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

It does not work. It says RESOURCE_NOT_FOUND

but when I do like this

resources/js/mainscript.js/1_0_0.js

It works. I do not like the way it is organized in the second way. First one looks cool. Any Idea?

I am using Tomcat 7.0, JSF 2.0.9

Update: I was checking primefaces-2-2.1.jar. Since when I checked the page source, I saw this /javax.faces.resource/jquery/jquery.js.xhtml?ln=primefaces&v=2.2.1">

Then I looked at META-INF/resources/primefaces/jquery/jquery.js

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


回答1:


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.

resources/default/1_0_0/js/mainscript.js

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:

@Override
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.



来源:https://stackoverflow.com/questions/9929417/jsf-resource-versioning

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!