У меня есть вопрос об интеграции библиотеки jquery с JSF 2.0
при использовании <h:outputScript library="/common/js" name="jquery-1.5.1.min.js" target="head" />, я должен включить тег <h:head> также в мой файл xhtml. так что скрипт выводится в начале.
<h:outputScript library="/common/js" name="jquery-1.5.1.min.js" target="head" />
<h:head>
но у меня есть template.xhtml, который содержит <h:head>,<h:body> частей. Как я могу сделать target="head" /> для моей страницы, которая получена из этого шаблона ui:composition="template.xhtml"?
<h:head>,<h:body>
target="head" />
ui:composition="template.xhtml"
target=form> тоже не работал.
target=form>
мой шаблон:
<?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>
так что у меня есть "icerik".
в моем файле:
<!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>
Я думаю, что лучший способ решил мою проблему: добавив <ui:insert name="icerikhead"></ui:insert> к головной части шаблона, а затем заполнив его в моей форме как <ui:define name="icerikhead"> add js files </ui:define>
<ui:insert name="icerikhead"></ui:insert>
<ui:define name="icerikhead"> add js files </ui:define>