Note that there are some explanatory texts on larger screens.

plurals
  1. POJSF to load CSS and JS in head section
    text
    copied!<p>I went through possible set of options from google and tried to include my 'js' and 'css' in <code>head</code> section how ever when I did page source the css and js files are getting append in <code>body</code> section, below are my code snippet:</p> <pre><code>&lt;h:head profile="http://www.w3.org/2005/10/profile"&gt; &lt;META charset="UTF-8" lang="en-US" /&gt; &lt;link rel="icon" type="image/png" href="#{resource['image:Friendsmirror.ico']}" /&gt; &lt;script type="text/javascript" src="#{facesContext.externalContext.requestContextPath}/resources/js/jquery-ui.min.js" /&gt; etc...... &lt;/h:head&gt; </code></pre> <p>and output as below: <img src="https://i.stack.imgur.com/yH4SY.png" alt="enter image description here"></p> <p>Below is the complete code: Template:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://xmlns.jcp.org/jsf/core" xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:p="http://primefaces.org/ui" xmlns:ui="http://xmlns.jcp.org/jsf/facelets" lang="#{languageBean.language}"&gt; &lt;!-- Enables CTRL+SHIFT+D for activating Facelets debug window --&gt; &lt;ui:debug /&gt; &lt;f:view locale="#{languageBean.language}"&gt; &lt;f:loadBundle var="messageResource" basename="MessageResource" /&gt; &lt;h:head profile="http://www.w3.org/2005/10/profile"&gt; &lt;META charset="UTF-8"/&gt; &lt;link rel="icon" type="image/png" href="#{resource['image:Friendsmirror.ico']}" /&gt; &lt;script type="text/javascript" src="#{facesContext.externalContext.requestContextPath}/resources/js/jquery-ui.min.js" /&gt; &lt;script type="text/javascript" src="#{facesContext.externalContext.requestContextPath}/resources/js/jquery.tooltipster.min.js" /&gt; &lt;script type="text/javascript" src="#{facesContext.externalContext.requestContextPath}/resources/js/jquery.tokeninput.js" /&gt; &lt;!-- &lt;script type="text/javascript" src="#{facesContext.externalContext.requestContextPath}/resources/js/connect_dashboard.js?some_var_to_bust_cache=24312341" /&gt;--&gt; &lt;script type="text/javascript" src="#{facesContext.externalContext.requestContextPath}/resources/js/moment.js" /&gt; &lt;script type="text/javascript" src="#{facesContext.externalContext.requestContextPath}/resources/js/livestamp.js" /&gt; &lt;script type="text/javascript" src="#{facesContext.externalContext.requestContextPath}/resources/js/jquery.watermark.min.js" /&gt; &lt;script type="text/javascript" src="#{facesContext.externalContext.requestContextPath}/resources/js/jquery.jeditable.mini.js" /&gt; &lt;script type="text/javascript" src="#{facesContext.externalContext.requestContextPath}/resources/js/jquery.autocomplete.js" /&gt; &lt;!-- For Input Range and Overlay --&gt; &lt;script type="text/javascript" src="#{facesContext.externalContext.requestContextPath}/resources/js/jquery.tools.min.js" /&gt; &lt;!-- slimScroll plugin --&gt; &lt;script type="text/javascript" src="#{facesContext.externalContext.requestContextPath}/resources/js/jquery.slimscroll.min.js" /&gt; &lt;link rel="stylesheet" type="text/css" href="#{facesContext.externalContext.requestContextPath}/resources/css/main.css?some_var_to_bust_cache=24312340" /&gt; &lt;link rel="stylesheet" type="text/css" href="#{facesContext.externalContext.requestContextPath}/resources/css/common.css?some_var_to_bust_cache=24312342" /&gt; &lt;link rel="stylesheet" type="text/css" href="#{facesContext.externalContext.requestContextPath}/resources/css/connect.css?some_var_to_bust_cache=24312340" /&gt; &lt;link rel="stylesheet" type="text/css" href="#{facesContext.externalContext.requestContextPath}/resources/css/token-input-facebook.css?some_var_to_bust_cache=24312345" /&gt; &lt;link rel="stylesheet" type="text/css" href="#{facesContext.externalContext.requestContextPath}/resources/css/tooltipster.css?some_var_to_bust_cache=24312340" /&gt; &lt;link rel="stylesheet" type="text/css" href="#{facesContext.externalContext.requestContextPath}/resources/css/skilltimeline.css" /&gt; &lt;link rel="stylesheet" type="text/css" href="#{facesContext.externalContext.requestContextPath}/resources/css/jquery.autocomplete.css" /&gt; &lt;f:facet name="first"&gt; &lt;meta http-equiv="X-UA-Compatible" content="EmulateIE8,IE=edge,chrome=1" /&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt; &lt;meta http-equiv="pragma" content="no-cache" /&gt; &lt;meta http-equiv="cache-control" content="no-cache" /&gt; &lt;meta http-equiv="expires" content="0" /&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1.0" /&gt; &lt;meta name="description" content="Connect" /&gt; &lt;meta name="keywords" content="timeline, 3d, css, css3, css-only, transitions, responsive, fluid" /&gt; &lt;meta name="author" content="FriendsMirror" /&gt; &lt;title&gt;&lt;ui:insert name="title"&gt;#{messageResource['expensecontrol.main.title']}&lt;/ui:insert&gt;&lt;/title&gt; &lt;/f:facet&gt; &lt;/h:head&gt; &lt;h:body&gt; &lt;p:outputPanel styleClass="content"&gt; &lt;h:outputScript target="head" name="connect_dashboard.js" library="js"/&gt; &lt;!--&lt;p:ajaxStatus styleClass="ajaxLoader" id="ajaxStatusPanel"&gt; &lt;f:facet name="start"&gt; &lt;h:graphicImage name="ajax-loader.gif" library="image" /&gt; &lt;/f:facet&gt; &lt;f:facet name="complete"&gt; &lt;h:outputText value="" /&gt; &lt;/f:facet&gt; &lt;f:facet name="error"&gt;An error has occurred!&lt;/f:facet&gt; &lt;/p:ajaxStatus&gt;--&gt; &lt;ui:insert name="header" /&gt; &lt;ui:insert name="body" /&gt; &lt;/p:outputPanel&gt; &lt;/h:body&gt; &lt;/f:view&gt; &lt;/html&gt; </code></pre> <p>and using template as:</p> <pre><code>&lt;ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://xmlns.jcp.org/jsf/core" xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:p="http://primefaces.org/ui" xmlns:ui="http://xmlns.jcp.org/jsf/facelets" template="/templates/common_layout.xhtml"&gt; &lt;ui:define name="title"&gt; Jayaram Pradhan &lt;/ui:define&gt; &lt;ui:define name="header"&gt; &lt;ui:include src="/templates/connectHome_Banner.xhtml" /&gt; &lt;/ui:define&gt; &lt;ui:define name="body"&gt; &lt;p:panel header="TEST Goes Here"&gt; &lt;h:form&gt; &lt;h:link value="Click Here" outcome="connect"&gt; &lt;f:param name="sessionKey" value="1234" /&gt; &lt;/h:link&gt; &lt;/h:form&gt; &lt;/p:panel&gt; &lt;/ui:define&gt; &lt;/ui:composition&gt; </code></pre> <p>I have tried with </p> <pre><code>&lt;h:outputScript target="head" name="connect_dashboard.js" library="js"/&gt; &lt;h:outputStylesheet/&gt; </code></pre> <p>as well <code>&lt;script&gt;</code> and but still js or css getting append to body only.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload