标签: facelets

JSF使用普通/原始XHTML/XML/EL源返回空白/未解析页面,而不是呈现HTML输出

我有一些Facelets文件,如下所示.

WebContent
 |-- index.xhtml
 |-- register.xhtml
 |-- templates
 |    |--userForm.xhtml
 |    `--banner.xhtml
 :

两个页面都使用/templates目录中的模板.我/index.xhtml在浏览器中打开了.我得到生成的HTML输出.我在/index.xhtml文件中有一个链接/register.xhtml文件.但是,我/register.xhtml没有被解析并返回为普通的XHTML/raw XML而不是生成的HTML输出.当我在浏览器中右键单击页面并执行查看页面源代码时,我仍然看到XHTML源代码而不是生成的HTML输出.看起来模板没有得到应用.

但是,当我在浏览器的地址栏中打开#{...}相似内容<h:body>时,它会正确显示.这是怎么造成的,我该如何解决?

jsf facelets el jsf-2

18
推荐指数
1
解决办法
1万
查看次数

jsf 2.0中的隐形评论?

是否可以在我的.xhtml文件中嵌入注释,这些注释只显示在源代码而不是渲染结果中?我想在文件中包含author,date,...但它们不应该在生成的输出中对最终用户可见.如果我使用标准评论标签 <!-- -->,浏览器会显示它们.

jsf comments invisible facelets jsf-2

18
推荐指数
2
解决办法
1万
查看次数

为什么getter被渲染属性调用了这么多次?

与前面的示例相关,我试图在服务器上监视我的get/set方法(当它们被调用时,以及多久).所以,我的实际看起来像这样:

@ManagedBean(name="selector")
@RequestScoped
public class Selector {
    @ManagedProperty(value="#{param.profilePage}")
    private String profilePage;

    public String getProfilePage() {
        if(profilePage==null || profilePage.trim().isEmpty()) {
            this.profilePage="main";
        }

        System.out.println("GET "+profilePage);

        return profilePage;
    }
    public void setProfilePage(String profilePage) { 
        this.profilePage=profilePage; 
        System.out.println("SET "+profilePage); 
    }
}
Run Code Online (Sandbox Code Playgroud)

并且唯一可以调用此方法的页面(它只调用渲染时的get方法)是:

<!DOCTYPE html>
<ui:composition
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets">

    <h:panelGroup layout="block" id="profileContent">
        <h:panelGroup rendered="#{selector.profilePage=='main'}">
            // nothing at the moment
        </h:panelGroup>
    </h:panelGroup>
</ui:composition>
Run Code Online (Sandbox Code Playgroud)

当我看到服务器日志时,我的昏迷,我看到:

SET null
GET main
GET main
GET main
GET main
GET main
GET main
GET main
Run Code Online (Sandbox Code Playgroud)

什么?它调用七次getProfilePage()方法?(也是1次setProfilePage())我想知道为什么这个行为:)

谢谢

添加了一个例子 …

getter jsf facelets jsf-2

18
推荐指数
1
解决办法
1万
查看次数

JSF/Facelets:使用<h:outputStylesheet>标记无法识别CSS文件

我正在使用JSF/Facelets开发一个项目.我想在我的View XHTML上做一些CSS更改,但是当我在Tomcat服务器中部署我的Web应用程序时没有任何反应.我尝试了很多技巧,但我得到了相同的结果.

无论如何,这是我的"styles.css":

body { width: 750px; }

#header 
{
width:              100%;
font-size:          36px;
font-weight:        bold;
line-height:        48px;
background-color:   navy;
color:              white;
}

#footer
{
width:              100%;
font-weight:        bold;
background-color:   navy;
color:              white;
}
Run Code Online (Sandbox Code Playgroud)

这是主要模板"Template.html",包括"Header.html"和"Footer.html",其中我使用标签放置我的"styles.css":

<!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:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<head>
<h:outputStylesheet name="css/styles.css" />
    <!-- i've also tried this one, using the "library" attribute -->
    <!--
     <h:outputStylesheet library="css" name="styles.css" />
    -->
</head>
<h:body>
<h:panelGroup id="page" layout="block">

    <h:panelGroup id="header" layout="block">
        <ui:insert name="header">
            <ui:include …
Run Code Online (Sandbox Code Playgroud)

html css jsf facelets

18
推荐指数
1
解决办法
4万
查看次数

Eclipse Facelet HTML Validator:无法将表达式运算符应用于方法绑定

Eclipse Facelet HTML Validator针对以下行报告错误"无法将表达式运算符应用于方法绑定":

<ui:fragment rendered="#{!empty managedBean.getSomething('ENUM_VALUE', someInt)}">
Run Code Online (Sandbox Code Playgroud)

我在Juno帮助中找到了这个(我正在使用Kepler):

Applying operator to method binding
#{bean.action * 5}
If bean.action indicates a method "action()" on bean, then it is not legal EL to treat its result as a value. In the example, multiplying action by 5 attempts treat it is as a value.
Run Code Online (Sandbox Code Playgroud)

我无法理解为什么将结果视为价值是不合法的?那么编写EL的正确方法是什么?谢谢!

eclipse validation facelets el jsf-2

18
推荐指数
2
解决办法
1万
查看次数

<ui:debug />标记在Facelets中不起作用(JSF 2.0)

我正在使用JSF 2.0和Facelets做一个项目.

我已经阅读<ui:debug/>了有关按下CTRL-SHIFT-D时标签提供有价值的故障排除信息的文档.但这对我不起作用.请有人告诉我我错过了什么.

(我试过各种热键,仍然没有成功例如:. <ui:debug hotkey="a"/>)

java jsf facelets

17
推荐指数
2
解决办法
2万
查看次数

将操作方法​​名称作为参数传递给facelets组件

我正在调用模板,并传递如下参数:

<ui:include src="WEB-INF/Subviews/ProductEdit.xhtml">
    <ui:param name="items" value="#{produtList}"></ui:param>
    <ui:param name="itemToEdit" value="#{productToEdit}"></ui:param>
</ui:include>
Run Code Online (Sandbox Code Playgroud)

在ProductEdit.xhtml中,我有类似的东西

<ui:repeat value="#{items}" var="item">
  <tr>
    ...
    ...
    <td style="text-align: center">
      <h:commandLink style="cssGenericColumn" action="#{productEditAction}">
         <f:setPropertyActionListener target="#{itemToEdit}" value="#{item}"/>
      </h:commandLink>    
    </td>
  <tr>
</ui:repeat>
Run Code Online (Sandbox Code Playgroud)

哪个工作正常.

我现在想在ProductEdit.xhtml中参数化#{productEditAction},所以我做了以下

<ui:include src="WEB-INF/Subviews/ProductEdit.xhtml">
    <ui:param name="items" value="#{produtList}"></ui:param>
    <ui:param name="itemToEdit" value="#{productToEdit}"></ui:param>
    <ui:param name="itemEditAction" value="#{productEditAction}"></ui:param>
</ui:include>
Run Code Online (Sandbox Code Playgroud)

在第一页然后在ProductEdit.xhtml中我做

<ui:repeat value="#{items}" var="item">
  <tr>
    ...
    ...
    <td style="text-align: center">
      <h:commandLink style="cssGenericColumn" action="#{itemEditAction}">
         <f:setPropertyActionListener target="#{itemToEdit}" value="#{item}"/>
      </h:commandLink>    
    </td>
  <tr>
</ui:repeat>
Run Code Online (Sandbox Code Playgroud)

这导致以下错误失败

javax.faces.el.EvaluationException: /WEB-INF/Subviews/ProductEdit.xhtml @45,89 action="#{itemEditAction}": Identity 'itemEditAction' does not reference a MethodExpression instance, returned type: java.lang.String …
Run Code Online (Sandbox Code Playgroud)

jsf facelets myfaces

17
推荐指数
1
解决办法
9585
查看次数

JSF和Facelets有什么区别?

我正在关注Java EE6教程,我不明白JSF和Facelets之间的区别.第4章有一节"开发一个简单的JavaServerFaces应用程序",第5章有一节"开发一个简单的Facelets"应用程序,据我所知,这两个例子都使用完全相同的过程 - 标记的.xhmtl页面,一个用于保存一些数据的辅助bean,然后是一个将url映射到'FaceletsServlet'的web.xml文件.

从我可以收集到的Facelets是带有标记的.xhtml页面,例如用于标记网页的<h:head>和<h:inputText>.

但那JSF是什么?我已经读过JSP或Facelets可以和JSF一起使用,这是否意味着JSF的作用是提供JSP或Facelets使用的标记库?

jsf facelets

17
推荐指数
2
解决办法
2万
查看次数

如何在JSF中使用Internet Explorer条件注释?

这是我在Eclipse中的源代码文件:

<!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">
<head>

<!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>

<body>

</body>
</html>
Run Code Online (Sandbox Code Playgroud)

当我在IE9中查看它时,它呈现文本:

<!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]-->
Run Code Online (Sandbox Code Playgroud)

如果我查看来源它说:

<!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">
<head>

<!--[if lt IE 9]&gt;

      &lt;script src=&quot;http://html5shim.googlecode.com/svn/trunk/html5.js&quot;&gt;&lt;/script&gt;

    &lt;![endif]-->
</head>

<body>


</body>
</html>
Run Code Online (Sandbox Code Playgroud)

Faces Servlet服务后源已更改的任何原因?

jsf internet-explorer facelets conditional-comments jsf-2

17
推荐指数
2
解决办法
6421
查看次数

打开Facelets页面错误,"此XML文件似乎没有与之关联的任何样式信息".

我正在尝试在其他计算机上的Apache Tomcat上运行我的Eclipse JSF项目.我用本教程创建了一个WAR文件.但是,当我部署WAR并在Firefox中打开Facelet页面时,我只收到以下错误消息:

此XML文件似乎没有与之关联的任何样式信息.文档树如下所示.

这是我第一次尝试在没有Eclipse的情况下运行我的JSF应用程序.这是怎么造成的,我该如何解决?

我实际上是在尝试打开以下Facelet页面:

<?xml version="1.0" encoding="UTF-8"?>
<ui:composition template="/WEB-INF/templates/template_a.xhtml"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets">
    <ui:define name="title">
        tytol
    </ui:define>
</ui:composition>
Run Code Online (Sandbox Code Playgroud)

xml eclipse jsf facelets

17
推荐指数
2
解决办法
18万
查看次数