仅使用 Primefaces 数据表对 JSF 进行操作审计
我目前正在审核项目上的用户操作,但遇到以下问题。
有一个名为“审核日志”的功能,它列出了用户在我的系统上执行的完整审核操作集。每当某个用户列出审核日志时,此操作也需要审核。
审核日志的 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>
我当前对特定代码片段进行审核操作:
<p:dataTable var="auditEntry"
value="#{auditList.allAuditEntries}"
paginator="true"
rows="10"
paginatorPosition="top"
dynamic="false">
我的支持 bean:
public List<AuditEntry> getAllAuditEntries()
{
auditFacade.createAuditEntry(function that creates an audit entry);
return allAuditEntries;
}
对支持 bean 的指定操作执行审核的问题如下:
需要一种方法来注册一次查询审核日志,而不是图像上显示的那样。有什么想法吗?有什么方法可以使用 JSF 或相关标签来保证上述内容?
TL;DR JSF 页面上只有一个 PrimeFaces 数据表,如何以在单行上进行审核注册的方式审核此类页面的打开,而不是如图所示。
Pd:重新编辑所有重复的审计条目并按时间差过滤它们是不可行的
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果可以将 ManagedBean 放入 RequestScope 中,您可以在 bean 的构造函数中调用 createAuditEntry 方法。然后每个请求只调用一次。
问候。
if it is possible to put the ManagedBean in RequestScope you could call the
createAuditEntry
method in the bean`s constructor. Then it is only called once per request.Regards.
解决了我的问题。
支持 bean 现在是
ViewScoped
,我刚刚创建了一个布尔变量,它确保每个 BeanViewScope
周期仅执行一次审核。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 BeanViewScope
cycle.