gpt4 book ai didi

jsf - target problem when using templates

转载 作者:行者123 更新时间:2023-12-04 15:50:23 27 4
gpt4 key购买 nike

我有一个关于将 jquery 库与 JSF 2.0 集成的问题

使用时 <h:outputScript library="/common/js" name="jquery-1.5.1.min.js" target="head" /> , 我应该包括 <h:head>标记也在我的 xhtml 文件中。所以脚本在头部呈现。

但我有一个包含 <h:head>,<h:body> 的 template.xhtml部分。我该如何制作 target="head" />对于源自此模板的我的页面 ui:composition="template.xhtml" ?
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>

关于jsf - <h :outputScript> target problem when using templates,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5954963/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com