简体   繁体   English

仅带有Primefaces数据表的JSF上的操作审核

[英]Action Audit on a JSF with just a Primefaces DataTable

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: 制作审核日志的JSF页面如下:

<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: 对后备bean的命名操作执行审核的问题如下: 泛滥的审核日志1泛滥的审核日志2

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? 有什么方法可以保证上述效果的JSF或相关标签?

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. TL; DR在JSF页面上只有一个PrimeFaces DataTable,如何以一种使审计注册位于一行的方式来审计该页面的打开,而不是如图所示。
Pd: It isnt feasible to re-edit all the repetitive audit entries filtering them by time difference Pd:重新编辑所有重复审计条目(按时差过滤它们)是不可行的

if it is possible to put the ManagedBean in RequestScope you could call the createAuditEntry method in the bean`s constructor. 如果可以将ManagedBean放入RequestScope中,则可以在bean的构造函数中调用createAuditEntry方法。 Then it is only called once per request. 然后,每个请求仅调用一次。

Regards. 问候。

Solved my problem. 解决了我的问题。
The backing bean is now ViewScoped and I just created a Boolean variable which ensures the Auditing is only done once per Bean ViewScope cycle. 支持bean现在是ViewScoped ,我刚刚创建了一个布尔变量,以确保每个Bean ViewScope周期仅执行一次审核。

public List<AuditEntry> getAllAuditEntries()
    {
        if (!isViewed)
        {
            isViewed = true;
            auditFacade.createAuditEntry(
                __creates Audit Entry here__);
        }

        return allAuditEntries;
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM