Hi guys,
I have page which consists of couple fragments and in the "header" fragment I have this tag <webuijsf:script id="script_logo" url="/resources/logo.js"/>
. This is rendered in HTML as <script src="/app/resources/logo.js" type="text/javascript" id="Header:script_logo"></script>
. This is fine and it is working as expected. Now I need to force JSF somehow to return URL to the javascript with current version of app. This is known technique for forcing the reload of resource (javascript, css and images) in case they are cashed on client's side. I need to render something like <script src="/app/resources/logo.js?ver=1.0.405" type="text/javascript" id="Header:script_logo"></script>
. Please note the ver
parameter in the URL.
Thanks.
Tomas
views:
38answers:
1
+2
A:
Well, you can simply add it to the page:
<script src="/app/resources/logo.js?ver=#{commonBean.version}" ...>
I've assumed you want to version to be configurable and sent by the server, so commonBean
is some jsf bean that returns the proper version.
Update: also take a look at <rich:loadScritp>
. (from RichFaces)
The final option is to create your own component and include the version automatically. Look for tutorial for how to make that, it's not easy for JSF 1.2
Bozho
2010-09-28 05:52:59
I was thinking about something more generic where I don't have to go through the code and add to every occurence of the `<script>` tag some new stuff. Something like servlet which will be mapped to the '/resource/' path and do the trick to add some artificial parameter. Or a new renderer for the `<script>` tag which will do the same as the servlet.
Tomas Babic
2010-09-28 20:08:34
@Tomas Babic it wouldn't be much of a difference. Anyway, see my update.
Bozho
2010-09-28 20:22:22
@Bozho it does make difference. I don't want to go through every page and fragment and update all ocurences of my images, css and scripts tags with this `?ver=#{someBean.version}` code. There has to be more generic aproach.
Tomas Babic
2010-09-29 01:53:00
@Tomas Babic - you can make your own component. But it's not easy.
Bozho
2010-09-29 05:08:12
You would be ready in less time than the time you needed for this question :)
BalusC
2010-09-29 11:12:28