我正在使用一个带有ui的页面:组合使用就像这样
<?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:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title></title>
</h:head>
<h:body>
<ui:composition template="./WEB-INF/templates/layout.xhtml">
<ui:define name="title">#{faqAddUpdate.actionState} FAQ</ui:define>
<ui:define name="content">
<h:form id="faqAddUpdateForm" style="border-color: #000000;width: 960px;position: absolute;left: 150px;" prependId="false">
....
....
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud)
我的layout.xhtml看起来像这样
<?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:h="http://java.sun.com/jsf/html">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="textext/javascript" src="ckeditor/ckeditor.js" >
<ui:insert name="script"></ui:insert>
</script>
<title>
<ui:insert name="title">Login</ui:insert>
</title>
</h:head>
<h:body>
<div id="top">
<ui:insert name="top">
<ui:include src="header.xhtml" id="header"/>
</ui:insert>
</div>
<div>
<div id="content">
<ui:insert name="content"></ui:insert>
</div>
</div>
<div id="bottom" style="position: absolute;top: 675px;width: 100%" align="center">
<ui:insert name="bottom">
<ui:include src="footer.xhtml" id="footer"/>
</ui:insert>
</div>
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud)
在我的页面上,我使用的是这样的东西
<h:body>
<ui:composition template="./WEB-INF/templates/layout.xhtml">
<ui:define name="script"></ui:define>
<ui:define name="title">#{faqAddUpdate.actionState} FAQ</ui:define>
<ui:define name="content">
....
</ui:define>
</ui:composition>
Run Code Online (Sandbox Code Playgroud)
这在我的页面部分添加javascript标签.现在我想问我是否要在我的页面上添加另一个.js文件.我将不得不在我的layout.xhtml页面中定义另一个ui:insert name ="script"?
<script type="textext/javascript" src="js/1.js" >
<ui:insert name="script"></ui:insert>
</script>
<script type="textext/javascript" src="js/2.js" >
<ui:insert name="script"></ui:insert>
</script>
Run Code Online (Sandbox Code Playgroud)
等等.或者有什么技巧我在layout.xhtml中定义脚本标记一次然后在src属性的基础上,我将它插入我的ui:组合页面?
谢谢
Rav*_*avi 14
您不必使用ui:inserts执行此操作.无论您何时需要在页面中添加javascript文件.只需使用资源API添加如下.
<h:outputScript library="javascript" name="1.js" target="head" />
Run Code Online (Sandbox Code Playgroud)
对于这个创建文件夹WebContent/resources/javascript并将1.js放在javascript文件夹中.
| 归档时间: |
|
| 查看次数: |
18627 次 |
| 最近记录: |