I have a JSF page where there is a Primefaces data table. So of the rows can have a extra data, which I want to display in a dialog.
When I load the page the data is retrived twice from the database This is log messages when get data from the database.
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
When I press the Dialog link, This is log messages when get data from the database.
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
Before the Dialog box is displayed.
Why? The JSF page looks like this:
<?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>