I am currently auditing the user actions on a project and I am having the following Issue.
There is a functionality called Audit Log, which lists the complete set of Audited actions performed by the user on my system. Whenever a certain user lists the Audit Log this action needs to be Audited as well.
The JSF page the Audit Log is made is the following:
<ui:composition ...>
<ui:define name="content">
<h:form id="audit_List">
<h:panelGrid columns="1">
<p:breadCrumb>
<p:menuitem value="#{i18n['xxx']}" url="index.xhtml" />
<p:menuitem value="#{i18n['yyy']}"/>
</p:breadCrumb>
<p:panel header="#{i18n['zzz']}">
<p:dataTable var="auditEntry"
value="#{auditList.allAuditEntries}"
paginator="true"
rows="10"
paginatorPosition="top"
dynamic="false">
<p:column sortBy="#{i18n[auditEntry.category]}"
filterBy="#{i18n[auditEntry.category]}">
A column here
</p:column>
<p:column sortBy="#{auditEntryDescriptionI18N[auditEntry]}"
filterBy="#{auditEntryDescriptionI18N[auditEntry]}">
A column here
</p:column>
<p:column sortBy="#{auditEntry.username}"
filterBy="#{auditEntry.username}">
A column here
</p:column>
<p:column id="problematicColumn"
sortBy="#{auditEntry.occurredOn}"
filterBy="#{auditEntry.occurredOn}">
<f:facet name="header">
<h:outputText value="#{i18n['aaa']}"/>
</f:facet>
<h:outputText value="#{auditEntry.occurredOn}">
<f:convertDateTime type="date"
___I suspect pattern is giving the problem..___
pattern="{auditList.listDateFormat.stringValue}"
timeZone="#{sessionBean.serverTimeZone}"/>
</h:outputText>
</p:column>
</p:dataTable>
</p:panel>
</h:panelGrid>
</h:form>
</ui:define>
</ui:composition>
I have currently the Auditing action on the particular code snippet:
<p:dataTable var="auditEntry"
value="#{auditList.allAuditEntries}"
paginator="true"
rows="10"
paginatorPosition="top"
dynamic="false">
My backing bean:
public List<AuditEntry> getAllAuditEntries()
{
auditFacade.createAuditEntry(function that creates an audit entry);
return allAuditEntries;
}
The problem of performing the auditting on the named action of the backing bean is the following:


Need a way to have the registration of consulting the Audit Log just once, and not as it is being shown on the images. Any ideas? Any way to user a JSF or related tag that will guarantee the above?
TL;DR Having just a PrimeFaces DataTable on a JSF page, how to audit the opening of such page in a way to have the audit registration on a single row, not as shown on the images.
Pd: It isnt feasible to re-edit all the repetitive audit entries filtering them by time difference
Solved my problem.
The backing bean is now
ViewScopedand I just created a Boolean variable which ensures the Auditing is only done once per BeanViewScopecycle.