我有一个JSF布局,每次启动服务器时都会遇到此错误:
/ 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 :(得分: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>