开发者

<h:outputScript> target problem when using templates

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 should include <h:head> tag also in my xhtml file. so script is rendered at 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> didn'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">

开发者_如何学Python<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>


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>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜