0

我有一个 JSF 布局,每次启动服务器时都会出现此错误:

/ UI 初始化错误
center-pane 元素不存在
center-pane 是必需元素

这是我的代码

 <?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition 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:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui">

    <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>Meu Sistema</title>
        <style type="text/css">
            body {background-color: #eeeeee; font-size: 12px}
        </style> 
    </h:head>
    <h:body>
        <div align="center">

            <p:layout style="min-width:1200px;max-width:1020px;min-height:600px">  
                <p:layoutUnit position="north" size="250">  
                    <h:graphicImage url="/images/funemac.png"  />
                </p:layoutUnit>  

                <p:layoutUnit position="west" size="220">  

                        <h:form>
                            <p:menu style="width: 200px">
                                <p:submenu label="Menu">
                                    <p:menuitem value="Início" action="index?faces-redirect=true"/>
                                </p:submenu>
                                <p:submenu label="Autor">
                                    <p:menuitem value="Novo" action="NovoAutor?faces-redirect=true"/>
                                    <p:menuitem value="Consulta" action="ConsultaAutor?faces-redirect=true"/>
                                </p:submenu>
                                <p:submenu label="Artigo">
                                    <p:menuitem value="Novo" action="EnvioArtigo?faces-redirect=true"/>
                                    <p:menuitem value="Consulta" action="ConsultaArtigo?faces-redirect=true"/>
                                    <p:menuitem value="Avaliação" action="Avaliacoes?faces-redirect=true"/>
                                </p:submenu>
                                <p:submenu label="Revisor">
                                    <p:menuitem value="Novo" action="NovoRevisor?faces-redirect=true"/>
                                    <p:menuitem value="Consulta" action="ConsultaRevisor?faces-redirect=true"/>
                                </p:submenu>
                                <p:submenu label="Tema">
                                    <p:menuitem value="Novo" action="NovoTema?faces-redirect=true"/>
                                    <p:menuitem value="Consulta" action="ConsultaTema?faces-redirect=true"/>
                                </p:submenu>
                                <p:submenu label="Evento">
                                    <p:menuitem value="Novo" action="NovoEvento?faces-redirect=true"/>
                                    <p:menuitem value="Consulta" action="ConsultaEvento?faces-redirect=true"/>
                                </p:submenu>
                                <p:submenu label="Relatórios">
                                    <p:menuitem value="Novo" action="Relatorios?faces-redirect=true"/>                                    
                                </p:submenu>
                                <p:submenu label="Inscrições">
                                   <p:menuitem value="Aluno" action="NovoParticipanteAluno?faces-redirect=true"/>                                    
                                    <p:menuitem value="Não Aluno" action="NovoParticipanteNaoAluno?faces-redirect=true"/>                                    
                                    <p:menuitem value="Palestrante" action="NovoParticipantePalestrante?faces-redirect=true"/>  
                                    <p:menuitem value="Inscrever-se em Evento" action="InscreverEmEvento?faces-redirect=true"/>  
                                    <p:menuitem value="Consulta" action="ConsultaInscricao?faces-redirect=true"/>                                     
                                </p:submenu>
                            </p:menu>
                        </h:form>

                </p:layoutUnit>  
                <p:layoutUnit position="center">  
                    <ui:insert name="centro">
                        Bem-Vindo!
                    </ui:insert>
                </p:layoutUnit>  
            </p:layout>  
        </div>
    </h:body>
</html>

这是一个奇怪的事实:当我收到这条消息时,我只是删除了这部分代码:

<p:submenu label="Inscrições">
                               <p:menuitem value="Aluno" action="NovoParticipanteAluno?faces-redirect=true"/>                                    
                                <p:menuitem value="Não Aluno" action="NovoParticipanteNaoAluno?faces-redirect=true"/>                                    
                                <p:menuitem value="Palestrante" action="NovoParticipantePalestrante?faces-redirect=true"/>  
                                <p:menuitem value="Inscrever-se em Evento" action="InscreverEmEvento?faces-redirect=true"/>  
                                <p:menuitem value="Consulta" action="ConsultaInscricao?faces-redirect=true"/>                                     
                            </p:submenu>

保存。并刷新页面,让一切正常。然后,全部放回去,当我再次刷新页面时,它就可以工作了。

问题是每次我重新运行我的服务器时都会发生这种情况。

谁能告诉我出了什么问题?

4

1 回答 1

0

你没有做错任何事。我发现 PrimeFaces 中的 MenuBar 对菜单中的项目数量相当挑剔。尝试在 menuItems 之间放置一个分隔符。

<p:submenu label="Separated">
   <p:menuitem value="Item1" url="#"/>                                 
   <p:menuitem value="Item2" url="#"/>
   <p:separator />
   <p:menuitem value="Item3" url="#"/> 
   <p:menuitem value="Item4" url="#"/>                               
</p:submenu>
于 2013-08-29T00:01:59.267 回答