2013-06-27 155 views
0

我有一個JSF佈局,每次我開始我的服務器我得到這個錯誤時間:UI佈局初始化錯誤

/UI初始化錯誤
中心窗格的元素不存在
中心窗格是必需的元素

這裏是我的代碼

<?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> 

保存。並刷新頁面,使一切正常。然後,所有回來,當我再次刷新頁面它的作品。

問題是我每次重新運行服務器時都會發生這種情況。

誰能告訴我什麼是錯的?

回答

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>