p:selectOneMenu呈现奇怪

问题描述 投票:0回答:1

按照PrimeFaces getting-started page上的说明,我看到来自SelectOneMenu的奇怪渲染。它看起来不像我期望的那样。有谁知道为什么?

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:p="http://primefaces.org/ui">

   <h:body>

      <h:form>
         <p:selectOneMenu id ="selectOneMenuCategorie" value="#{selectOneController.categorieSelected}" >
            <f:selectItem itemLabel="Select One" noSelectionOption="true"/>
            <f:selectItems value="#{selectOneController.categorieList}"
                           var = "c" itemLabel="#{c.libelle}" itemValue="#{c}"/>
            <f:ajax render="selected_item1"/>
         </p:selectOneMenu>

         <h:outputText id="selected_item1" value="#{selectOneController.categorieSelected.libelle}"></h:outputText>

      </h:form>
   </h:body>
</html>
primefaces
1个回答
0
投票

你应该添加

 <h:head>
</h:head>

标记到您的xhtml页面。

<h:head>是一个JSF组件,它提供了一个钩子,可以在生成的HTML <head>中以编程方式包含JavaScript和CSS资源。 PrimeFaces使用它来包含Ajax工作所需的JS / CSS代码和花哨的look'n'feel。

作为测试,创建一个包含<h:head>PrimeFaces组件的页面,打开webbrowser中的页面并通过rightclick检查生成的HTML源代码 - 查看源代码。您将看到添加了几个JSF和PrimeFaces特定的JS / CSS文件。现在用<h:head>替换<head>并再次检查生成的HTML源代码,这次你什么也看不见。

© www.soinside.com 2019 - 2024. All rights reserved.