我的网站有一个通用模板,即xhtml file
,同时包含growl
<p:growl id="message" showDetail="true" life="3000" />
此模板在所有页面中进一步使用。我注意到growl
适用于页面index.xhtml
,但未在其余页面中使用。以下是faces-config.xml
文件的摘要 -
<navigation-rule>
<display-name>index.xhtml</display-name>
<from-view-id>/index.xhtml</from-view-id>
<navigation-case>
<from-outcome>NORMAL_USER</from-outcome>
<to-view-id>/home.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
但每当我通过链接home.xhtml
访问网页http://localhost:8080/portal/home.xhtml
时,growl
就会开始工作。在我使用update=":message"
更新growl
的所有网页中。哪个是罪魁祸首?
以下是index.xhtml
<ui:composition template="/template/common/base.xhtml"
xmlns="http://www.w3.org/1999/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="center">
<h:form>
<div align="center" style="margin-top: 10%; margin-bottom: 10%;">
<p:panelGrid columns="2">
<f:facet name="header">
#{msg.HEADER}
</f:facet>
<h:outputLabel for="username" value="#{msg.USERNAME}" />
<p:inputText id="username" value="#{client.user.username}"
required="true" requiredMessage="#{msg.USERNAME_REQUIRED_MSG}" />
<h:outputLabel for="password" value="#{msg.PASSWORD} " />
<p:password id="password" value="#{client.user.password}"
required="true" requiredMessage="#{msg.PASSWORD_REQUIRED_MSG}" />
<f:facet name="footer">
<div align="right">
<p:commandButton value="#{msg.LOGIN_BUTTON}" icon="ui-icon-check"
update=":message" action="#{client.login}" />
</div>
</f:facet>
</p:panelGrid>
</div>
</h:form>
</ui:define>
</ui:composition>
以下是base.xhtml
<!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:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>My Web Portal</title>
<h:outputStylesheet library="css" name="default.css" />
</h:head>
<h:body>
<p:growl id="message" showDetail="true" life="3000" />
<h:link outcome="index" style="text-decoration: none;">
<div id="header" style="margin: 2px; width: 100%; text-align: center;">
<p:panel>
<h:outputText value="My Web Portal"
style="font-size: 20px; " />
</p:panel>
</div>
</h:link>
<div id="middle" style="margin: auto; width: 80%;">
<ui:insert name="center"></ui:insert>
</div>
<div id="footer"
style="clear: both; text-align: center; margin: 2px; width: 100%;">
<p:panel header="2013 All rights reserved. Designed by Ravi Joshi">
<h:link value="Home" outcome="index" />
<p:spacer width="10px;" />
<h:link value="About Us" outcome="index" />
<p:spacer width="10px;" />
</p:panel>
</div>
</h:body>
</html>
下一页home.xhtml
也使用base.xhtml
,就像index.xhtml
使用它一样......下面是它的片段 -
<ui:composition template="/template/common/base.xhtml"
xmlns="http://www.w3.org/1999/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="center">
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
</ui:define>
</ui:composition>