< h:outputScript>使用模板时的目标问题 [英] <h:outputScript> target problem when using templates

查看:65
本文介绍了< h:outputScript>使用模板时的目标问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对将jquery库与JSF 2.0集成有疑问

I have a question about integrating jquery library with JSF 2.0

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

when using <h:outputScript library="/common/js" name="jquery-1.5.1.min.js" target="head" /> , i should include <h:head> tag also in my xhtml file. so script is rendered at head.

但是我有一个包含<h:head>,<h:body>部分的template.xhtml.我如何为从该模板ui:composition="template.xhtml"派生的页面制作target="head" />?

but i have a template.xhtml that contains <h:head>,<h:body> parts. How can i make target="head" /> for my page that derives from this template 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".

so i have "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>

I think a better way solved my problem : adding <ui:insert name="icerikhead"></ui:insert> to template's head part and then filling it in my form as <ui:define name="icerikhead"> add js files </ui:define>

这篇关于&lt; h:outputScript&gt;使用模板时的目标问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆