在我的代码中,我有一个xhmtl页面,它有一个p:poll(primefaces)。每5秒更新一次panelMap(我的面板)。当地图更新时,它必须显示3个带有咆哮的消息,问题是它显示更多3个,然后我得到6个消息。我尝试了很多差异。方式和无法解决。
视图
<ui:composition template="/WEB-INF/template/Layout.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui" xmlns:o="http://omnifaces.org/ui">
<title>Monitoramento</title>
<f:metadata>
<f:event listener="#{gadoBean.obterPosicaoTag}" type="preRenderView" />
</f:metadata>
<ui:define name="corpo">
<script
src="https://maps.googleapis.com/maps/api/js?key="mykey"
type="text/javascript"></script>
<h:form prependId="false">
<h:panelGrid columns="3">
<p:poll interval="5" listener="#{gadoBean.obterPosicaoTag}"
update="panelMap" />
<p:button value="Adicionar Pasto" outcome="/area/criarArea.xhtml" />
<p:button value="Mudar animal de pasto"
outcome="/propriedade/mudarAnimal.xhtml" />
</h:panelGrid>
<p:panel id="panelMap" header="Monitoramento"
footer="clique sobre o pasto desejado para obter suas informações"
style="margin-top:30px;margin-left:230px;width:700px;max-width:100%;height:450px;max-height:100%">
<p:growl id="growl" showDetail="false" sticky="true" />
<p:gmap id="mapa" center="#{gadoBean.center}" zoom="17"
model="#{gadoBean.mapa}" type="HYBRID"
style="width:862px;height:400px;max-width:100%;max-height:100%">
<p:ajax event="pointSelect"
listener="#{gadoBean.aoSelecionarPonto}" update="growl" />
</p:gmap>
</p:panel>
</h:form>
</ui:define>
</ui:composition>
答案 0 :(得分:0)
您必须为growl
添加生命,以便3个第一条消息在5秒之前消失,然后当p:poll
在5秒后更新panelMap
时,另外3条消息显示up,life="4500"
(4500毫秒):
<p:growl id="growl" showDetail="false" sticky="true" life="4500" />