<h: outputScript> target problem when using patterns

I have a question about integrating jquery library with JSF 2.0

when using <h:outputScript library="/common/js" name="jquery-1.5.1.min.js" target="head" /> I have to add the <h:head> also to my xhtml file. therefore the script is displayed on the head.

but I have a template.xhtml containing the <h:head>,<h:body> parts. How can I do target="head" /> for my page that comes from this ui:composition="template.xhtml" template ui:composition="template.xhtml" ?

target=form> doesn't work either.

my template:

 <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.prime.com.tr/ui" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"> <h:head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title><h:outputText value="#{msg['label.titlemsg']}" /></title> <h:outputStylesheet library="css" name="style.css" target="head"/> </h:head> <h:body> <f:view locale="#{localeBean.locale}"> <div id="outer"> <div id="container"> <div id="inner"> <div class="float"> <div class="main"> <!-- --> <div id="icerik"> <ui:insert name="icerik"> </ui:insert> </div></div></div></div></div></div> <div id="langbar" align="center"> </div> </f:view> </h:body> </html> 

so i have "icerik".

in my file:

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.prime.com.tr/ui" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"> <ui:composition template="/Template.xhtml"> <ui:define name="icerik"> <h:outputScript library="/common/js" name="jquery-1.5.1.min.js" target="head" /> <h:outputScript library="/common/js" name="jquery.validate.js" target="head" /> </ui:define> </ui:composition> </html> 
+5
source share
1 answer

I think the best way solved my problem: by adding <ui:insert name="icerikhead"></ui:insert> to the part of the template chapter, and then filling it in my form as <ui:define name="icerikhead"> add js files </ui:define>

+6
source

All Articles