I have a problem with the order of JQuery imports. In the head section I do:
<h:head>
<f:facet name="first">
<h:outputScript library="primefaces" name="jquery/jquery.js" target="head" />
</f:facet>
<f:facet name="middle">
<h:outputScript library="primefaces" name="jquery/jquery-plugins.js" target="head" />
</f:facet>
...
The first time my page is loaded everything seems correct, especially the jquery/jquery-plugins order:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head id="j_idt2">
<link type="text/css" rel="stylesheet" href="/installateurportal/javax.faces.resource/theme.css.jsf?ln=primefaces-aristo" />
<link type="text/css" rel="stylesheet" href="/installateurportal/javax.faces.resource/components.css.jsf?ln=primefaces&v=6.0" />
<link type="text/css" rel="stylesheet" href="/installateurportal/javax.faces.resource/css/default/core.css.jsf?ln=bsf" />
<link type="text/css" rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
<link type="text/css" rel="stylesheet" href="/installateurportal/javax.faces.resource/css/bsf.css.jsf?ln=bsf" />
<!--[if lt IE 9]><script src="/installateurportal/javax.faces.resource/js/html5shiv.js.jsf?ln=bsf"></script><script src="/installateurportal/javax.faces.resource/js/respond.js.jsf?ln=bsf"></script><![endif]-->
<script type="text/javascript" src="/installateurportal/javax.faces.resource/jquery/jquery.js.jsf?ln=primefaces&v=6.0"></script>
<script type="text/javascript" src="/installateurportal/javax.faces.resource/jquery/jquery-plugins.js.jsf?ln=primefaces&v=6.0"></script>
<script type="text/javascript" src="/installateurportal/javax.faces.resource/core.js.jsf?ln=primefaces&v=6.0"></script>
...
On the page are buttons like
<h:commandLink styleClass="btn btn-mini btn-default"
actionListener="#{testController['filterTable']}">
<i class="fa fa-refresh"/>
</h:commandLink>
After pressing one of them the page is loaded again with errors in JS-Console like
Uncaught ReferenceError: jQuery is not defined
at tbmDisposition-aendernPF.jsf:3
VM219 jquery-plugins.js.jsf?ln=primefaces&v=6.0:5 Uncaught ReferenceError: jQuery is not defined
at VM219 jquery-plugins.js.jsf?ln=primefaces&v=6.0:5
at VM219 jquery-plugins.js.jsf?ln=primefaces&v=6.0:5
And when you look at the generated html:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head id="j_idt2">
<link type="text/css" rel="stylesheet" href="/installateurportal/javax.faces.resource/theme.css.jsf?ln=primefaces-aristo" />
<link type="text/css" rel="stylesheet" href="/installateurportal/javax.faces.resource/css/default/core.css.jsf?ln=bsf" />
<link type="text/css" rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
<link type="text/css" rel="stylesheet" href="/installateurportal/javax.faces.resource/css/bsf.css.jsf?ln=bsf" />
<!--[if lt IE 9]><script src="/installateurportal/javax.faces.resource/js/html5shiv.js.jsf?ln=bsf"></script><script src="/installateurportal/javax.faces.resource/js/respond.js.jsf?ln=bsf"></script><![endif]-->
<link type="text/css" rel="stylesheet" href="/installateurportal/javax.faces.resource/components.css.jsf?ln=primefaces&v=6.0" />
<script type="text/javascript" src="/installateurportal/javax.faces.resource/jquery/jquery-plugins.js.jsf?ln=primefaces&v=6.0"></script>
<script type="text/javascript" src="/installateurportal/javax.faces.resource/jquery/jquery.js.jsf?ln=primefaces&v=6.0"></script>
<script type="text/javascript" src="/installateurportal/javax.faces.resource/core.js.jsf?ln=primefaces&v=6.0"></script>
...
You can see that jquery-plugins is above jquery which causes the described error.
Of course I tried various alternatives in the head section without success, so any help would be appreciated.
Version informations
PrimeFacs: 6.0
JSF: 1.2_15-jbossorg-2
Server: jboss-as-7.1.2.Final
Greetings Kai
Update: Debugging the HeadRenderer I found out that the HeadRenderer doesn't seem to be responsible for JQuery at all. It must have something to do with ResourceDependencies of the Widget and how they are rendered. Does anyone know which renderer might be responsible for ResourceDependencies?
Update 2: Besides I am using BootsFaces for the layout. Now I learned that BootsFaces has its own JQuery and resource optimization as well ...
Update 3: In the ResourceFileComparator of BootsFaces the JS files will be renamed like
if (name.contains("jquery-ui")) name = "2.js"; // make it the second JS file
else if (name.contains("jquery")) name = "1.js"; // make it the first JS file
But in my case the name for jquery-ui is: "jquery/jquery-plugins.js" => Both "jquery/jquery.js" and "jquery/jquery-plugins.js" will be renamed to "1.js"
I started an issue at BootsFaces-OSP (https://github.com/TheCoder4eu/BootsFaces-OSP/issues/640) and found a workaround (described in the issue). So now it works for me.