我在这里遇到了麻烦.我有一个JSF应用程序,它有一个名为baseTemplate.xhtml的模板文件.该文件位于/ resources/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: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" />
<h:outputStylesheet library="css" name="default.css"/>
<h:outputStylesheet library="css" name="cssLayout.css"/>
<h:outputStylesheet library="css" name="menu.css"/>
<h:outputStylesheet library="css" name="rodape.css"/>
<title>JSF Project</title>
</h:head>
<h:body>
<div id="estrutura">
<div class="top">
<ui:insert name="top">
<ui:include src="somefile"/>
</ui:insert>
</div>
<div id="menu">
<ui:insert name="menu">
<ui:include src="somefile"/>
</ui:insert>
</div>
<div>
<div id="left">
<ui:insert name="left">
</ui:insert>
</div>
<div id="content" class="left_content">
<ui:insert name="content"></ui:insert>
</div>
</div>
<div id="bottom">
<ui:insert name="bottom">
<ui:include …Run Code Online (Sandbox Code Playgroud) 早上好,我在主要表面上应用样式表时遇到问题commandButton,按钮元素如下:
<p:commandButton value="Complains" styleClass="styleOrange"/>
Run Code Online (Sandbox Code Playgroud)
和样式表:
.styleOrange {
background-color: orange;
}
Run Code Online (Sandbox Code Playgroud)
css文件放在css文件夹下的resources文件夹中:
这是css文件的include语句:
<h:head>
<h:outputStylesheet name="/resources/css/style.css" library="css" />
</h:head>
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用IE条件注释来声明CSS资源:
<h:outputStylesheet name="common.css" library="css" />
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="#{resource['css:ie.css']}" />
<![endif]-->
Run Code Online (Sandbox Code Playgroud)
但是,这似乎不起作用.我在生成的HTML输出中看到了这个:
<link type="text/css" rel="stylesheet" href="/context/faces/javax.faces.resource/common.css?ln=css" />
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="/context/faces/javax.faces.resource/ie.css?ln=css"/>
<![endif]-->
Run Code Online (Sandbox Code Playgroud)
没有条件注释,它工作正常.我没有使用context参数javax.faces.FACELETS_SKIP_COMMENTS.这是怎么造成的,我该如何解决?
我是开发JSF的新手(一般是Web开发的新手),我试图在页面上放置一个图像.我正在Eclipse中开发我的JSF应用程序并在Glassfish 3.1.2上运行它.我已将Glassfish注册为Eclipse中的服务器,并通过Eclipse运行应用程序.
我在xhtml页面上使用以下标记:
<h:graphicImage library="images" name="logo.png"/>
Run Code Online (Sandbox Code Playgroud)
我在META-INF/resources/images/logo.png中复制了图像.图像没有出现在页面上,当我查看页面源时,我看到了元素
<img src="RES_NOT_FOUND" />
Run Code Online (Sandbox Code Playgroud)
表示未找到图像.
当我将我的应用程序导出到war文件并通过autodeploy文件夹将其部署到Glassfish时,我得到相同的结果 - 页面显示,但图像不会出现.
任何人都可以建议为什么没有找到图像资源?
是否有必要给文件夹命名为"资源"做一个css文件和js文件的引用时h:outputStylesheet和h:outputScript?
因为当我给出文件夹名称"assets"而不是"resources"时,这些文件不会被加载.
这就是我使用这些标签的方式:
<h:head>
<h:outputStylesheet name="css/styles.css"/>
<h:outputScript name="js/site.js"/>
</h:head>
Run Code Online (Sandbox Code Playgroud)
这是我的项目结构:

在屏幕截图中,您可以看到文件夹名称是资源.然后它正在运作.如何指定其他名称?
我有一个JSF应用程序,其中一些脚本使用target ="head"属性插入,但在将Primefaces 3.5包含到类路径后,这些脚本将停止渲染.
这是页面代码:
<!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"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
</h:head>
<h:body>
<h:outputScript target="head">
function a(){};
</h:outputScript>
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud)
删除目标属性会使脚本正常,但是在正文中,而不是在头部...
有线索吗?感谢和问候.
我有一个像这样的JSF复合组件:
<cc:implementation>
<div id="#{cc.clientId}">
<h:outputScript library="js" name="helper.js"/>
<script type="text/javascript">
if(typeof variables === "undefined"){
var variables = {};
}
(function(){
variables.formid = '#{cc.clientId}';
})();
</script>
</div>
Run Code Online (Sandbox Code Playgroud)
variables.formid我在helper.js文件中使用的价值.当我只包含一次这个复合组件时,它就像它应该的那样工作.当我包含多个复合组件时,每个组件都会收到最后包含的复合组件的值,如何解决此问题?
我实现了一个jsf 2.0组件,它应该显示jQuery的Datepicker.它工作正常,但找不到css中引用的图像.找到了*.js和*.css,但没有找到图像的链接.
这是我的组件的代码
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!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:c="http://java.sun.com/jsp/jstl/core"
xmlns:cc="http://java.sun.com/jsf/composite">
<head>
<title>jQuery - Datepicker</title>
</head>
<body>
<cc:interface>
<cc:editableValueHolder name="input"/>
</cc:interface>
<cc:implementation>
<h:outputStylesheet library="stats" name="jquery/css/jquery-ui-1.8.16.custom.css" />
<h:outputScript library="stats" name="jquery/js/jquery-1.7.1.min.js" target="head"/>
<h:outputScript library="stats" name="jquery/js/jquery-ui-1.8.17.custom.min.js" target="head"/>
<script type="text/javascript">
var jq = jQuery.noConflict();
jq(document).ready(function() {
jq("[id$=#{cc.clientId}]").datepicker({
showOn : 'focus',
duration : 10,
changeMonth : true,
changeYear : true,
dayNamesMin : ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'],
currentText : 'Heute',
dateFormat : 'dd-mm-yy',
yearRange …Run Code Online (Sandbox Code Playgroud) 在JSF页面中,我使用EL来查找放在/resource/images/文件夹中的图像.
<h:graphicImage value="#{resource['images:logo.gif']}"
Run Code Online (Sandbox Code Playgroud)
EL如何定位图像?也许规范定义了规则,但我不知道哪个规范.我尝试在JSR-000344 JavaServer Faces 2.2,JSR-000342 Java平台,企业版7,JSR-000341表达式语言3.0中找到它,但没找到.