jsf - Primefaces 无法加载 PanelMenu 组件

标签 jsf primefaces

我在我的项目中使用 primefaces。当我在 .xhtml 页面之一使用该组件时,我收到以下错误消息:

“标签库支持命名空间:http://primefaces.org/ui,但没有为名称定义标签:panelMenu”

我正在使用 primefaces 3.3.1 jar 。

代码片段:

<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:p="http://primefaces.org/ui">
<h:head>
    <title>Welcome to OTV_JSF_Spring_Hibernate_Project</title>
<style type="text/css">
h1{
    font-family:"Times New Roman";
    font-size:7px;
  }

pre{
    font-family:"Times New Roman";
    font-size:25px;
    font-style:bold;
    align:center;
}
</style>
</h:head>
<h:body>
    <h:form>

         <p:layout style="min-width:300px;min-height:700px;" id="layout">  
             <p:layoutUnit position="east" resizable="true" size="300" minSize="40" maxSize="300">  
               <p:panelMenu style="width:200px">  
                     <p:submenu label="Create Form">  
                        <p:menuitem value="New Form" actionListener="" icon="ui-icon-disk" />  
                        <p:menuitem value="Current Form" actionListener=""  icon="ui-icon-arrowrefresh-1-w" />  
                        <p:menuitem value="Form Templates" actionListener=""  icon="ui-icon-arrowrefresh-1-w" />
                     </p:submenu>  

                <p:submenu label="Publish Form" >  
                    <p:menuitem value="Home" actionListener=""  ajax="false" icon="ui-icon-close"/>  
                    <p:menuitem value="Docs" actionListener=""  ajax="false" icon="ui-icon-close"/>  
                </p:submenu>  
                 <p:submenu label="Users Profile">  
                         <p:menuitem value="Add New User" actionListener=""  ajax="false" icon="ui-icon-close"/>  
                         <p:menuitem value="Edit User Profile" actionListener=""  ajax="false" icon="ui-icon-close"/>
                         <p:menuitem value="Remove Users" actionListener=""  ajax="false" icon="ui-icon-close"/>
                         <p:menuitem value="View Users Report" actionListener=""  ajax="false" icon="ui-icon-close"/>
                     </p:submenu>  
                <p:separator />  

            </p:panelMenu>   
       </p:layoutUnit>  

         <p:layoutUnit position="center">  
         <h1><font size = "6"><h:outputLabel for="createform" value="Create New Form"/></font></h1>
         <hr width="98%"></hr>
             <table> 

             <tr>
                <td width="30%"><pre><h:outputLabel for="name" value="Name of the form : " /></pre></td>
                <td align="left"><p:inputText id="name" value="#{questionMB.formName}" label="Name of the form">
                </p:inputText>
                    <p:message id="formMsg" for="name" display="icon"/> 

                </td>
             </tr>   
              <tr>
                <td width="30%"><pre><h:outputLabel for="desc" value="Description of the form : " /></pre></td>
                <td align="left"><p:inputTextarea rows="4" cols="60" value="#{questionMB.formDesc}"/>
                </td>
             </tr>            
             <tr>
              <td width="30%"><pre><h:outputLabel for="question" value="Question : " /></pre></td>
                <td align="left">
                    <p:accordionPanel>  
    <p:tab title="Godfather Part I">  
        <h:panelGrid columns="2" cellpadding="10">  

           <p:inputText id="question" value="#{questionMB.questionText}">
                        <f:validateLength minimum="5" /> 
                        <p:ajax event="blur" update="questionMsg" />
                    </p:inputText>
                    <p:message id="questionMsg" for="question" display="icon"/> 
        </h:panelGrid>  
    </p:tab>  
   </p:accordionPanel>
                </td> 
             </tr>
              <tr>
                <td width="30%"><pre><h:outputLabel for="answer" value="Answer Type : " /></pre></td>
                <td align="center">
      <h:panelGrid columns="2" rows="1" style="margin-bottom:10px" cellpadding="5">  
            <p:selectOneRadio id="options" value="#{questionMB.answerType}">  
            <f:selectItem itemLabel="Text field" itemValue="Text field" />  
            <f:selectItem itemLabel="Combo box" itemValue="Combo box" />  
            <f:selectItem itemLabel="Radio button" itemValue="Radio button" />  
            <f:selectItem itemLabel="Check box" itemValue="Check box" />
            <f:selectItem itemLabel="Date box" itemValue="Date box" /> 
            <f:selectItem itemLabel="Y/N Button" itemValue="Y/N Button" />
             </p:selectOneRadio>  
     </h:panelGrid>  
                </td>
             </tr>
             <tr></tr><tr></tr><tr></tr>

             <tr>
                <td></td><td></td>
                <td><p:commandButton id="addNewQuestion" value="Add New Question" action="#{questionMB.addNewQuestion}" ajax="true"/>
               </td>
             </tr> 
             <tr>
                <td></td><td></td>
                <td><p:commandButton id="addQuestion" value="Save" action="#{questionMB.addQuestion}" ajax="true"/>
                <p:commandButton id="submitQuestion" value="Submit" action="#{questionMB.saveandsubmitForm}" ajax="false"/></td>
             </tr>
             </table> 
         </p:layoutUnit>  
</p:layout>   


    </h:form>
</h:body>

</html>

最佳答案

您收到该错误是因为 p:panelMenu 不是 3.3.1 版本。 3.4 中有介绍。 查看3.3.1 here的文档

关于jsf - Primefaces 无法加载 PanelMenu 组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12370516/

相关文章:

validation - 验证 JSF 中的小数输入

java - 如何在不提交的情况下测试数据库中是否存在某个值?

jsf - <p :selectManyMenu var> throws ELException: The class 'java.lang.String' does not have the property 'foo'

java - 异常 JSF 从数据库中删除

java - 导出包含超过 256 列且带有 primefaces 的 Excel

jsf - <f :ajax> listener not working in nested <p:overlayPanel>

java - JSF 项目的组件库

pdf - PrimeFaces p :media not working with StreamedContent in a @ViewScoped bean

jsf - 为什么我能够绑定(bind) <f :actionListener> to an arbitrary method if it's not supported by JSF?

jsf - 基于 Primefaces 的 <p :diagram> 创建自定义组件