我正在使用primefaces v4.0。我在我的xhtml中设置了一个f:event listener = {..} type = preRenderView。侦听器方法也被正确调用,但此侦听器方法使用导航处理程序执行导航。观察到的是导航完成并加载第二页后,第二页的菜单没有按预期显示。似乎有一些css / js没有加载。下面是我的xhtml模板,其中包含菜单代码。
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html 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:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
>
<h:head>
<f:facet name="first">
<meta http-equiv="X-UA-Compatible" content="EmulateIE8" />
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
<title>CBB-Questionnaire</title>
</f:facet>
<link type="text/css" rel="stylesheet" href="#{resource['css:template.css']}" />
</h:head>
<h:body >
<p:tooltip />
<div class="qestDiv" >
<div class="header">
<h:form id="homeform">
<p:menubar >
<p:submenu label="Questionnaire" icon="ui-icon-document" >
<p:menuitem value="Technology Outsourcing" action="TechQuestionnaireForOutSrc"
icon="ui-icon-document" id="TECHQ1"
actionListener="#{usersession.questSelectedSetInSession}"/>
</p:submenu>
</p:menubar>
</h:form>
</div>
<div class="content">
<div class="centerpane">
<div class="pageContent">
<ui:insert name="pageContent" />
</div>
</div>
</div>
</div>
<div class="footer">
</div>
</h:body>
</html>
page1.xhtml is below navigates to page2.xhtml
<ui:composition template="/WEB-INF/templates/template.xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
>
<ui:define name="pageContent" >
<f:event listener="#{techQOutSrcbean.checkSubmissionStatusAndNavigate}" type="preRenderView" />
</ui:define>
</ui:composition>
page2.xhtml
<ui:composition template="/WEB-INF/templates/template.xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
>
<ui:define name="pageContent" >
</ui:define>
</ui:composition>
当page2.xhtml加载时,它应该显示在teh模板中定义的菜单,因为我正在使用facelets。但是第2页的菜单会加载,但会加载为
下面是html源代码,它告诉js未加载到菜单加载不完整的页面上。
<!-- taken from the page where menu loads properly -->
<meta http-equiv="X-UA-Compatible" content="EmulateIE8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>CBB-Questionnaire</title><link href="/QuestionaireWeb/faces/javax.faces.resource/theme.css?ln=primefaces-aristo" rel="stylesheet" type="text/css"><link href="/QuestionaireWeb/faces/javax.faces.resource/primefaces.css?ln=primefaces&v=4.0" rel="stylesheet" type="text/css"><script src="/QuestionaireWeb/faces/javax.faces.resource/jquery/jquery.js?ln=primefaces&v=4.0" type="text/javascript"></script><script src="/QuestionaireWeb/faces/javax.faces.resource/jquery/jquery-plugins.js?ln=primefaces&v=4.0" type="text/javascript"></script><script src="/QuestionaireWeb/faces/javax.faces.resource/primefaces.js?ln=primefaces&v=4.0" type="text/javascript"></script><link href="/QuestionaireWeb/faces/javax.faces.resource/css/template.css" rel="stylesheet" type="text/css">
<!-- taken from the page where js/css does not load properly fro the menu -->
<meta http-equiv="X-UA-Compatible" content="EmulateIE8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>CBB-Questionnaire</title><link href="/QuestionaireWeb/faces/javax.faces.resource/theme.css?ln=primefaces-aristo" rel="stylesheet" type="text/css"><link href="/QuestionaireWeb/faces/javax.faces.resource/css/template.css" rel="stylesheet" type="text/css">