标签: facelets

Facelets页面是作为JSP生成的Servlet生成的Servlet

由于所有JSP在执行之前都会生成/转换为Servlet,对于Facelets来说也是如此吗?

我正在使用JSF 2.0和Facelets,并希望看到它生成的Java代码可能是Servlet.

jsf compilation facelets

7
推荐指数
2
解决办法
1150
查看次数

JSF Facelets如何包含外部html?

我有一个正在开发的应用程序,我的公司有一个标题横幅,需要在所有页面上.我们在该标题横幅的团队中有大约6个不同的版本,我现在想要制作它以便我只是将源代码中的横幅包含到我的应用中,这样如果他们更新横幅的来源,我的应用版本的横幅也会自动更新.

使用<ui:include src="http://mycompany.com/banner.html" />导致错误The markup in the document following the root element must be well-formed..

即使它没有很好的形成xml,我怎么能包含这个横幅?

我目前的模板:

<!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:p="http://primefaces.org/ui"
    xmlns:ui="http://java.sun.com/jsf/facelets">

<ui:composition>

<h:body>
    <div>
      <ui:include src="http://mycompany.com/banner.html" />
    </div>

    <ui:insert name="content" />
</h:body>
</ui:composition>
</html>
Run Code Online (Sandbox Code Playgroud)

jsf facelets jsf-2

7
推荐指数
1
解决办法
5765
查看次数

在JSF-Richfaces-facelet中重定向会话超时

我正在使用JSF和RichFacecs来创建一个Web门户.我希望在会话超时时将用户重定向到登录页面.我试图在会话到期/注销阶段抛出SecurityException,如下所示

<error-page>
    <exception-type>java.lang.SecurityException</exception-type>
    <location>/Login.jsf</location>
</error-page>
Run Code Online (Sandbox Code Playgroud)

但这不适合我.处理这个问题的正确方法是什么?

jsf richfaces facelets

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

JSF <h:outputFormat>:使用数组值作为参数

在我的JSF2页面上,我正在使用国际化的错误消息.

在我的支持bean中,我将消息放入flash范围:

flash.put("error", exception.getType());
Run Code Online (Sandbox Code Playgroud)

在页面上,此字符串以这种方式翻译:

<h:outputText value="#{bundle[flash.error]}"/>
Run Code Online (Sandbox Code Playgroud)

工作良好.

现在我想能够将(任意数量的)参数放入消息文本中,这些参数将插入到message.properties中i18n属性的占位符中.因此,我将参数作为String数组放入Flash Scope中,如下所示:

//exception.getParameters returns String[]
flash.put("errorParams", exception.getParameters())
Run Code Online (Sandbox Code Playgroud)

现在我也希望能够使用这个String数组作为outputFormat元素的参数,将它们插入到像这样的属性中Welcome, {0} {1}.所以我试图通过使用ui实现这一点:重复:

<h:outputFormat value="#{bundle[flash.error]}" rendered="#{! empty flash.error}" class="invalid">
  <ui:repeat value="#{flash.errorParams}" var="_param">
    <f:param value="#{bundle[_param]}"/>
    <!-- also doesn't work: <f:param value="#{_param}"/>-->
  </ui:repeat>
</h:outputFormat>
Run Code Online (Sandbox Code Playgroud)

不幸的是,param值被忽略,并且i18n-property的占位符没有被替换,因此渲染的输出是Welcome, {0} {1}.当使用"常规"转发器时,将数组元素显示为输出文本,它可以工作.所以outputFormat标签似乎不支持使用repeat作为子元素.该死的,如此接近;)任何人都知道一个很好的方法来做我想要的,或者是否有任何组件库支持这样的东西?

jsf facelets jsf-2

6
推荐指数
1
解决办法
4827
查看次数

JSF 2.0自定义消息

我正在使用JSF 2.0.我正在使用

<h:messages>
Run Code Online (Sandbox Code Playgroud)

标记以呈现错误消息.我可以使用css来设置我的消息的样式,但是我创建了一个复合组件来呈现可以关闭的消息,并使用一些Jquery向它们添加效果.

我已经看过如何自定义消息的教程,但是大多数都依赖于CSS并自定义文本输出但我想要做的是生成特定的标记,类似于

<myComp:fancyMessage text="etcetcetc error msg" type="error" />
Run Code Online (Sandbox Code Playgroud)

而不是常规的消息标记.这可能吗?

编辑:

我不想设置jsf消息的样式.既不添加背景也不改变其风格,而是创建我自己的消息html标记.这里:

http://balusc.blogspot.com/2010/07/using-html-in-jsf-messages.html

我已经找到了如何在你的消息中添加html.我想要的是封装我的复合组件中的所有html,然后以这种方式使用我的复合组件:

<mycomp:messages/>
Run Code Online (Sandbox Code Playgroud)

要么

<mycomp:message for="componentID" />
Run Code Online (Sandbox Code Playgroud)

消息和消息都创建自己的html标记

java jsf message facelets jsf-2

6
推荐指数
1
解决办法
5720
查看次数

如何在Facelets/EL中逃避'$'和​​'#'?

我正在使用Java Facelets和jQuery,但是表达式

$('...')
Run Code Online (Sandbox Code Playgroud)

在jQuery与EL表达式冲突中,我如何逃避jQuery的一个?

我也想逃避大量的Javascript.

ANSWERED

要将现有的JSP转换为Facelets xhtml,只需将现有的javascript包装起来即可<![CDATA[ ... ]]>.但是,输出脚本<script><!-- -->注释包装,与CDATA部分冲突:

<script><![CDATA[ scripts... ]]></script>

=> <script><!-- <![CDATA[ scripts... ]]> --></script>
Run Code Online (Sandbox Code Playgroud)

要解决此问题,您还应注释掉CDATA:

<script>/* <![CDATA[ */ scripts... /* ]]> */</script>

=> <script><!-- /* <![CDATA[ */ scripts... /* ]]> */--></script>
Run Code Online (Sandbox Code Playgroud)

另请参见脚本标记中何时需要CDATA部分?.

escaping facelets el

6
推荐指数
2
解决办法
5083
查看次数

在EL for Facelets页面中使用not null而不是empty

在我的支持bean中,如果我有一个列表,那么我可以使用

rendered="#{not empty name}" or rendered="#{not null name}"
Run Code Online (Sandbox Code Playgroud)

对?但如果我只有实例变量(不是列表),那么我可以使用

rendered="#{not empty name}" ?
Run Code Online (Sandbox Code Playgroud)

jsf facelets el

6
推荐指数
0
解决办法
3万
查看次数

具有复合子元素的复合组件与ui一起使用时将值混合:重复

我试图通过嵌套一个孩子来使两个复合组件很好地协同工作.该设置包含一个灯箱和一个带有名为"Value"的属性的输入.这工作正常,直到我引入动态数量的输入,因此必须使用ui:repeat.

bugTest.xhtml

<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:pw="http://java.sun.com/jsf/composite/components">

    <h:head></h:head>
    <h:body>
        <pw:lightBox value="Header">
            <h:form>
                <ui:repeat var="input" value="#{BugTestBean.inputs}">
                    <pw:bugTestInput value="#{input}" />
                </ui:repeat>
            </h:form>
        </pw:lightBox>
    </h:body>
</html>
Run Code Online (Sandbox Code Playgroud)

ui:repeat似乎混淆了两个组件的value属性,并发生以下异常.

Caused by: javax.el.PropertyNotFoundException: /resources/components/bugTestInput.xhtml @15,62 value="#{cc.attrs.value.text}": The class 'java.lang.String' does not have the property 'text'.
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:111)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
at javax.faces.component.UIOutput.getValue(UIOutput.java:170)
at javax.faces.component.UIInput.getValue(UIInput.java:284)
at com.sun.faces.facelets.component.UIRepeat$SavedState.populate(UIRepeat.java:879)
at com.sun.faces.facelets.component.UIRepeat.saveChildState(UIRepeat.java:396)
at com.sun.faces.facelets.component.UIRepeat.saveChildState(UIRepeat.java:402)
at com.sun.faces.facelets.component.UIRepeat.saveChildState(UIRepeat.java:402)
at com.sun.faces.facelets.component.UIRepeat.saveChildState(UIRepeat.java:356)
at com.sun.faces.facelets.component.UIRepeat.setIndex(UIRepeat.java:470)
at com.sun.faces.facelets.component.UIRepeat.process(UIRepeat.java:586)
at com.sun.faces.facelets.component.UIRepeat.encodeChildren(UIRepeat.java:1042)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1819)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:847)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:304)
at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:105)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:847)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:304)
at …
Run Code Online (Sandbox Code Playgroud)

jsf facelets composite-component jsf-2 uirepeat

6
推荐指数
1
解决办法
1171
查看次数

Netbeans错误"属性目标未在组件outputStylesheet中定义"

我输入了以下代码:

<h:outputStylesheet library="css" name="style.css" target="body" />
Run Code Online (Sandbox Code Playgroud)

问题是它给我一个关于target ="body"的错误说:

The attribute target is not defined in the component outputStylesheet
Run Code Online (Sandbox Code Playgroud)

在html部分,如果html我有以下内容:

<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"
    xmlns:p="http://primefaces.org/ui"
    xmlns:pe="http://primefaces.org/ui/extensions">
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?

谢谢

jsf netbeans facelets

6
推荐指数
1
解决办法
2504
查看次数

JSF中的RES_NOT_FOUND

我读了很多帖子但没有成功解决这个问题.请帮忙....

Eclipse Juno/JSF

项目结构: 在此输入图像描述

teste.xhtml:

<!DOCTYPE html[
    <!ENTITY nbsp "&#160;"> 
    <!ENTITY copy "&#169;">
] >
<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">
<h:head>
  <h:outputScript library="js" name="slides.min.jquery.js"/>
  <h:graphicImage value="images/blog.png" />
  <h:outputStylesheet name="css/estilo.css"/>
  </h:head>
  <h:body>
  #{javax.faces.resource}
  </h:body>
  </html>
Run Code Online (Sandbox Code Playgroud)

输出是:

<link type="text/css" rel="stylesheet" href="RES_NOT_FOUND">
Run Code Online (Sandbox Code Playgroud)

与js和图像相同的res_not_found

pom.xml:

<dependencies>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>6.0</version>
        <scope>provided</scope>
    </dependency>

<dependency>
    <groupId>org.primefaces</groupId>
    <artifactId>primefaces</artifactId>
    <version>4.0</version>
</dependency>

<dependency>
    <groupId>org.primefaces.extensions</groupId>
    <artifactId>all-themes</artifactId>
    <version>1.0.8</version>
</dependency>

<dependency>
    <groupId>com.sun.facelets</groupId>
    <artifactId>jsf-facelets</artifactId>
    <version>1.1.14</version>
</dependency>


<dependency>
    <groupId>com.sun.faces</groupId>
    <artifactId>jsf-impl</artifactId>
    <version>2.1.23</version>
    <scope>provided</scope>
</dependency>

<dependency>
    <groupId>com.sun.faces</groupId>
    <artifactId>jsf-api</artifactId>
    <version>2.1.23</version>
    <scope>provided</scope>
</dependency>       

<dependency>
    <groupId>javax.faces</groupId>
    <artifactId>javax.faces-api</artifactId>
    <version>2.2</version>
</dependency> …
Run Code Online (Sandbox Code Playgroud)

css eclipse jsf jboss facelets

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