我有一个JSF页面,其中有一个Primefaces数据表。 所以行中可以有一个额外的数据,我想在对话框中显示。
当我加载页面时,数据将从数据库中重复两次 这是从数据库获取数据时的日志消息。
14:11:44,004 INFO [stdout] (http-localhost/127.0.0.1:8080-1) LogMessageProducer.getAllMessages:600 ms
14:11:44,325 INFO [stdout] (http-localhost/127.0.0.1:8080-1) LogMessageProducer.getAllMessages:165 ms
当我按下对话框链接时, 这是从数据库获取数据时的日志消息。
14:17:26,135 INFO [stdout] (http-localhost/127.0.0.1:8080-1) LogMessageProducer.getAllMessages:203 ms
14:17:26,416 INFO [stdout] (http-localhost/127.0.0.1:8080-1) LogMessageProducer.getAllMessages:156 ms
14:17:26,712 INFO [stdout] (http-localhost/127.0.0.1:8080-1) LogMessageProducer.getAllMessages:203 ms
14:17:27,024 INFO [stdout] (http-localhost/127.0.0.1:8080-1) LogMessageProducer.getAllMessages:187 ms
14:17:27,306 INFO [stdout] (http-localhost/127.0.0.1:8080-1) LogMessageProducer.getAllMessages:187 ms
14:17:27,602 INFO [stdout] (http-localhost/127.0.0.1:8080-1) LogMessageProducer.getAllMessages:187 ms
14:17:27,852 INFO [stdout] (http-localhost/127.0.0.1:8080-1) LogMessageBodyProducer.getOnId:156 ms
14:17:28,164 INFO [stdout] (http-localhost/127.0.0.1:8080-1) LogMessageProducer.getAllMessages:187 ms
14:17:28,430 INFO [stdout] (http-localhost/127.0.0.1:8080-1) LogMessageProducer.getAllMessages:171 ms
14:17:28,711 INFO [stdout] (http-localhost/127.0.0.1:8080-1) LogMessageProducer.getAllMessages:187 ms
在显示对话框之前。
为什么呢? JSF页面如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui" template="/WEB-INF/templates/default.xhtml">
<ui:define name="content">
<h:form id="form">
<p:dataTable var="_msg" value="#{logMessageProducer.allMessages}" reflow="true" rows="50" paginator="true" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="25,50,100,500,1000"
tableStyle="table-layout: auto;">
<p:column headerText="Id"><h:outputText value="#{_msg.id}" /></p:column>
<p:column headerText="CorrelationId"><h:outputText value="#{_msg.correlationId}" /></p:column>
<p:column headerText="Timestamp"><h:outputText value="#{_msg.timestamp}" /></p:column>
<p:column headerText="State"><h:outputText value="#{_msg.state}" /></p:column>
<p:column headerText="Host"><h:outputText value="#{_msg.host}" /></p:column>
<p:column headerText="Message"><h:outputText value="#{_msg.message}" /></p:column>
<p:column style="width:16px" headerText="File">
<p:commandLink value="Link" oncomplete="PF('test').show()" update=":form:dialog" rendered="#{not empty _msg.fk_body_id}">
<f:setPropertyActionListener target="#{mbean.selectedLogMessageBody}" value="#{logMessageBodyProducer.getOnId(_msg.fk_body_id)}" />
</p:commandLink>
</p:column>
</p:dataTable>
<p:dialog modal="true" width="500" height="500" widgetVar="test" id="dialog" header="File">
<p:panelGrid columns="2" columnClasses="label,value" style="table-layout: auto;">
<h:outputText value="Filename:" />
<h:outputText value="#{mbean.selectedLogMessageBody.fileName}" />
<h:outputText value="Extension:" />
<h:outputText value="#{mbean.selectedLogMessageBody.extension}" />
<h:outputText value="Size:" />
<h:outputText value="#{mbean.selectedLogMessageBody.fileSize}" />
<h:outputText value="Filelink:" />
<h:outputText value="#{mbean.selectedLogMessageBody.fileLink}" />
</p:panelGrid>
</p:dialog>
</h:form>
</p:panel>
</ui:define>
</ui:composition>