Performance PrimeFaces积垢按钮需要时间才能显示
我目前面临一个性能问题,我希望得到您的支持 以下是我的配置:Performance PrimeFaces积垢按钮需要时间才能显示,performance,jsf,jpa,netbeans,primefaces,Performance,Jsf,Jpa,Netbeans,Primefaces,我目前面临一个性能问题,我希望得到您的支持 以下是我的配置: NetBeans IDE 8.0.2(构建201411181905) Primefaces 5.2 nbpfcrudgen-0.30.1-8.0.2_patch1-impl(我用于我的应用程序的积垢发生器) Glassfish 4.0 PostgreSQL 9.2 我用Netbeans crud生成器()创建了一个crud应用程序 下面的代码显示了表中的操作列表。在页面底部有一个按钮“视图”,只有在您选择表中的一行时,该按钮才会激
- NetBeans IDE 8.0.2(构建201411181905)
- Primefaces 5.2
- nbpfcrudgen-0.30.1-8.0.2_patch1-impl(我用于我的应用程序的积垢发生器)
- Glassfish 4.0 PostgreSQL 9.2
<h:form id="ActionListForm">
<p:panel header="#{bundle.ListActionTitle}">
<p:dataTable id="datalist"
value="#{actionController.items}"
var="item"
rowKey="#{item.idaction}"
paginator="true"
rows="10"
rowsPerPageTemplate="10,20,30,40,50"
selectionMode="single"
selection="#{actionController.selected}">
<p:ajax event="rowSelect" update=":ActionListForm:viewButton" listener="#{actionController.resetParents}"/>
<p:ajax event="rowUnselect" update=":ActionListForm:viewButton" listener="#{actionController.resetParents}"/>
<p:ajax event="contextMenu" update=":ActionListForm:viewButton" listener="#{actionController.resetParents}"/>
<p:ajax event="rowDblselect" onsuccess="document.getElementById('ActionListForm:viewButton').click();"/>
<p:column sortBy="#{item.idaction}" filterBy="#{item.idaction}">
<f:facet name="header">
<h:outputText value="#{bundle.ListActionTitle_idaction}"/>
</f:facet>
<h:outputText value="#{item.idaction}"/>
</p:column>
<p:column sortBy="#{item.actionlink}" filterBy="#{item.actionlink}">
<f:facet name="header">
<h:outputText value="#{bundle.ListActionTitle_actionlink}"/>
</f:facet>
<h:outputText value="#{item.actionlink}"/>
</p:column>
<p:column sortBy="#{item.identity.name}" filterBy="#{item.identity.name}">
<f:facet name="header">
<h:outputText value="#{bundle.ListActionTitle_identity}"/>
</f:facet>
<h:outputText value="#{item.identity.name}"/>
</p:column>
</p:dataTable>
<p:commandButton id="viewButton" style="visibility: hidden;" icon="ui-icon-search" value="#{bundle.View}" update=":ActionViewForm" oncomplete="PF('ActionViewDialog').show()" disabled="#{empty actionController.selected}"/>
</h:form>
有人知道造成这种缓慢的原因吗?在这种情况下,您能帮我纠正我的错误吗?警告:代码生成器通常不会生成有效的代码。只有程序员才能编写高效的代码。是否缺少索引?为什么是jsf标记而不是jpa标记呢?还有offtopic:你的方法不应该被调用
findallbydentity
,所以你添加了jpa标记,但是你对瓶颈的确切位置做了分析吗?嗨,非常感谢你的帮助。是的,我按照你的建议添加了JPA标签,完全同意它是有意义的。我在编码领域很新,不太熟悉评测工具,我尝试在Firefox中使用dev插件,但没有成功。如果你能指导我使用这种工具,我将不胜感激。我会尝试索引,但我不明白为什么应用程序会查询数据库只是为了激活一个按钮。不管怎样,你的建议真的很有帮助,谢谢。
<h:form id="ActionListForm">
<p:panel header="#{bundle.ListActionTitle}">
<p:dataTable id="datalist"
Value = "#budgetController.getAllActionByEntity('bob’}"
public List<Action> getAllActionByEntity(String iduserparam) {
EntityManagerFactory emf = Persistence.createEntityManagerFactory("propensionPU");
EntityManager em = emf.createEntityManager();
try {
Entity identity = new Entity (iduserparam);
allActionByEntity = em.createNamedQuery("Action.findAllByEntity").setParameter("identity", identity).getResultList();
}
catch (NoResultException e) {System.out.println (e);}
return allActionByEntity;
}
@NamedQuery(name = "Action.findAllByEntity", query = "SELECT a FROM Action a WHERE a.identity = :identity")})