Jsf - <h:commandlink>在primefaces datatable </h:commandlink>中

时间:2013-12-17 07:43:18

标签: jsf jsf-2 primefaces

当表位于<h:commandLink />时,我需要在<p:dataTable />内设置selectionMode="multiple"。这是我的模拟代码。

<h:form id="myform">
   <p:dataTable id="myTable">
      <f:facet name="header"> 
         <h:commandLink value="Delete"  />

      </f:facet>
      <p:column selectionMode="multiple" />
       ....
       ....
   </p:dataTable>
</h:form>

<h:commandLink />datatable内显示正常。当我点击Delete链接显示某些NullPointerException时,会出现问题。这是错误代码。

HTTP Status 500 -

type Exception report

message

description The server encountered an internal error that prevented it from fulfilling this request.

exception

javax.servlet.ServletException
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
root cause

java.lang.NullPointerException
    org.primefaces.component.datatable.feature.SelectionFeature.decodeMultipleSelection(SelectionFeature.java:51)
    org.primefaces.component.datatable.feature.SelectionFeature.decode(SelectionFeature.java:40)
    org.primefaces.component.datatable.DataTableRenderer.decode(DataTableRenderer.java:60)
    javax.faces.component.UIComponentBase.decode(UIComponentBase.java:787)
    org.primefaces.component.api.UIData.processDecodes(UIData.java:232)
    javax.faces.component.UIForm.processDecodes(UIForm.java:225)
    javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1176)
    org.primefaces.component.tabview.TabView.processDecodes(TabView.java:317)
    javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1176)
    javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1176)
    javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:933)
    com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
    com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.47 logs.

Apache Tomcat/7.0.47

在我删除delete或设置<p:column selectionMode="multiple" />后点击selectionMode="single"后,该页面将重新加载。我希望这个行动阶段仅适用于我的模板项目。

我哪里出错了?

1 个答案:

答案 0 :(得分:0)

据我所知,当我们将选择设置为“multiple”时,arraylist将用于存储在辅助bean中使用的所选行。因此,当您单击删除时,将生成操作并且列表为空,因为您不会选择任何内容,它会给出错误。您正在使用的Plz邮政编码,以便我们可以快速完成此操作