JSF< f:facet>内容未呈现 [英] JSF <f:facet> contents not rendered

查看:186
本文介绍了JSF< f:facet>内容未呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面,我需要嵌入一些组件在< f:facet name =last> ,以便应用自定义样式使用Primefaces,这是他们处理CSS优先级顺序的方法,如这里)。但我无法呈现放置在< f:facet> 标签内的任何内容。

I have a page where I need to nest some components inside a <f:facet name="last>, in order to apply custom styles (I'm using Primefaces and this is their their way of handling CSS priority ordering as mentioned here). But I'm not able to render anything placed inside the <f:facet> tags.

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:p="http://primefaces.org/ui">
<h:head>
    <title>TODO supply a title</title>
</h:head>
<h:body>
    <div>
        <h:form>
            <h:outputLabel for="loginField" value="Login:" styleClass="form-label"/>
            <p:inputText id="loginField" value="#{subscriptionBean.login}" styleClass="form-field"/>
            <f:facet name="last">
                <h:outputLabel for="pwd2" value="Password:" styleClass="form-label"/>
                <p:password id="pwd2" value="#{subscriptionBean.password}" required="true" match="pwd1" styleClass="form-field"/>
                <p:message for="pwd2" display="text" styleClass="form-field"/>
            </f:facet>
        </h:form>
    </div>        
</h:body>

看到生成的页面中的密码输入字段?

Shouldn't I be able to see the password input field in the generated page? It simply doesn't show up.

以下starf的回答这里有一些示例代码:

Following starf's answer here's some sample code:

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:p="http://primefaces.org/ui">
<h:head>
    <f:facet name="last">
        <h:outputStylesheet library="css" name="default.css"/>
    </f:facet>
</h:head>

<h:body>
        <h:outputText value="Rendered text!"/>
        <h:form>
            <h:outputLabel for="pdw1" value="Password: "/>
            <p:password id="pwd1" required="true"/>
            <p:message for="pwd1"/>
        </h:form>

</h:body>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link type="text/css" rel="stylesheet" href="/AquitelManagement/faces/javax.faces.resource/default.css?ln=css" />
<link type="text/css" rel="stylesheet" href="/AquitelManagement/faces/javax.faces.resource/primefaces.css?ln=primefaces&amp;v=5.0.RC2" />
<script type="text/javascript" src="/AquitelManagement/faces/javax.faces.resource/jquery/jquery.js?ln=primefaces&amp;v=5.0.RC2">    
</script><script type="text/javascript" src="/AquitelManagement/faces/javax.faces.resource/jquery/jquery-plugins.js?ln=primefaces&amp;v=5.0.RC2">
</script>
<script type="text/javascript" src="/AquitelManagement/faces/javax.faces.resource/primefaces.js?ln=primefaces&amp;v=5.0.RC2">
</script>
</head>
<body>...


推荐答案

您尝试在h:form标记上注册一个facet。链接中的示例注册在h:head标记上。 Primefaces有一个自定义渲染器头。

You are trying to register a facet on the h:form tag. The example in the link is registered on the h:head tag. Primefaces has a custom renderer for head.

没有为窗体定义的facet,所以它不知道如何处理它。另请参见< f:facet>不能使用< h:form>

There is no such facet defined for form, so it doesn't know how to handle it. See also <f:facet> not working with <h:form>

我相信你混淆了css订购问题。如果你想覆盖PrimeFaces css,使用head中的lastfacet - 这将把css定义放在primefaces css下面。

I believe you are confusing the css ordering issue. If you wish to override the PrimeFaces css, use the "last" facet in the head - which would place your css definition below the primefaces css.

<h:head>
    <f:facet name="last">
        <h:outputStylesheet library="default" name="css/style.css" />
    </f:facet>
</h:head>

查看 http://www.mkyong.com/jsf2/primefaces/resource-ordering-in-primefaces/ 以获得更好的解释。

See http://www.mkyong.com/jsf2/primefaces/resource-ordering-in-primefaces/ for a good explanation.

这篇关于JSF&lt; f:facet&gt;内容未呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆