分拣NPE焦点问题单个视图JSF PrimeFaces多个数据表

问题描述 投票:0回答:1

我有一个问题PrimeFaces数据表。

我的情况:4个数据表上的一个视图。我只能够最后一个排序。我认为这是某种形式的重点就可以了。另一个表单击列标题,会导致以下NPE:

05-Feb-2019 11:55:03.542 SEVERE [http-nio-8080-exec-7] org.primefaces.application.exceptionhandler.PrimeExceptionHandler.logException null
 java.lang.NullPointerException
    at org.primefaces.component.datatable.DataTable.findColumnInGroup(DataTable.java:962)
    at org.primefaces.component.datatable.DataTable.findColumn(DataTable.java:953)
    at org.primefaces.component.datatable.feature.SortFeature.decode(SortFeature.java:86)
    at org.primefaces.component.datatable.DataTableRenderer.decode(DataTableRenderer.java:64)
    at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:478)
    at org.primefaces.component.api.UIData.processDecodes(UIData.java:287)
    at org.apache.myfaces.context.servlet.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:775)
    at org.apache.myfaces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:213)
    at org.primefaces.component.api.UIData.visitTree(UIData.java:827)
    at javax.faces.component.UIForm.visitTree(UIForm.java:345)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1044)
    at javax.faces.component.UIComponentBase.visitTree(UIComponentBase.java:1191)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1044)
    at javax.faces.component.UIComponentBase.visitTree(UIComponentBase.java:1191)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1044)
    at javax.faces.component.UIComponentBase.visitTree(UIComponentBase.java:1191).......

代码为每个视图是类似以下的 - 他们都在不同的形式

    <p:dataTable value="#{bean.list}" var="row" paginator="true" id="dataList#{formId}"
                 paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                 rowsPerPageTemplate="#{bean.tablePaginatorSizes}" rows="#{bean.tableDefaultPaginatorSize}"
                 emptyMessage="#{lang.label_no_records_found}"
                 selectionMode="single" rowKey="#{row.id}" widgetVar="packListTab">
   <p:column headerText="ID" sortBy="#{row.id.packageId}" filterBy="#{row.idStr}" filterMatchMode="contains"
                      width="150">
                <h:outputText value="#{row.idStr}"/>
            </p:column> 
</p:datatable>

PF 6.0版

编辑:

我升级PF到6.2,NPE不同的堆栈跟踪露面

java.lang.NullPointerException
    at org.primefaces.component.datatable.feature.SortFeature.decode(SortFeature.java:80)
    at org.primefaces.component.datatable.DataTableRenderer.decode(DataTableRenderer.java:71)
    at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:478)
    at org.primefaces.component.api.UIData.processDecodes(UIData.java:296)
    at org.apache.myfaces.context.servlet.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:775)
    at org.apache.myfaces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:213)
    at org.primefaces.component.api.UIData.visitTree(UIData.java:850)
    at javax.faces.component.UIForm.visitTree(UIForm.java:345)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1044)
    at javax.faces.component.UIComponentBase.visitTree(UIComponentBase.java:1191)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1044)
    at javax.faces.component.UIComponentBase.visitTree(UIComponentBase.java:1191)

debug result

这很奇怪,客户端是从另一种形式(最后一个)比列。

jsf primefaces
1个回答
1
投票

在NPE确实seemes一直在Primefaces tracked by issue 2059其中null支票遗失可为空的对象引用的错误。升级到6.1 Primefaces应该解决这个NPE。

通过检查堆栈跟踪在Eclipse Java StackTrace console与Primefaces 6.0源代码发现这个比较该DataTable.findColumnInGroup(...)的方法实现与一个在Primefaces 6.1源代码。后者包含null检查:

public UIColumn findColumnInGroup(String clientId, ColumnGroup group) {
    if(group == null) {
        return null;
    }

    FacesContext context = this.getFacesContext();

    for(UIComponent row : group.getChildren()) {
    // ...
    }
}

Blaming the change in source tree向我指出上述问题跟踪。

© www.soinside.com 2019 - 2024. All rights reserved.