Primefaces服务器上的Datatable CellEditor空指针异常

时间:2017-02-01 17:17:38

标签: jsf primefaces jsf-2 datatable xhtml

我有一个xhtml页面来显示具有可编辑逐行单元格的延迟加载数据表。当我运行应用程序服务器时它工作正常,但是当我在linux服务器中部署它时它不起作用。我附加了我的代码和错误日志

XHTML

    <?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://xmlns.jcp.org/jsf/core"
    xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:hx="http://xmlns.jcp.org/jsf/passthrough"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:jsf="http://xmlns.jcp.org/jsf" xmlns:p="http://primefaces.org/ui">
<h:head>
    <meta content="text/html; charset=utf-8" http-equiv="content-type" />
    <title>SMS Dasboard</title>
    <link rel="shortcut icon" href="../assets/images/favicon.ico" />
    <!-- Bootstrap core CSS     -->
    <link href="../assets/css/bootstrap.min.css" rel="stylesheet" />

    <!-- Animation library for notifications   -->
    <link href="../assets/css/animate.min.css" rel="stylesheet" />
    <link href="../assets/css/style.css" rel="stylesheet" />
</h:head>

<h:body>
    <div id="wrapper">

        <!-- Top -->
        <div class="container">
            <div class="row">
                <div class="top">
                    <div class="col-lg-6">
                        <a href="index.xhtml"><img src="../assets/images/logo.png"
                            class="brand" alt="" /></a>
                    </div>
                    <div class="col-lg-6 pull-right">
                        <div class="links">
                            <ul>
                                <li><a href="#"><img
                                        src="../assets/images/settings.png" alt="" /> Settings</a></li>
                                <li><p:inputText name="" type="button"
                                        value="SMS Balance : 89,000"
                                        styleClass="btn balancebtn btn-default" /></li>
                                <li><a href="#"><img src="../assets/images/logout.png"
                                        alt=""></img> Logout</a></li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- Top End -->

        <!--   Main End  -->

        <section class="mainsec">
        <div class="container">
            <div class="row">

                <!--  Sidebar  -->
                <div class="col-lg-2">
                    <div class="sidebar">
                        <div class="headings pink">
                            <h3>latest activities</h3>
                        </div>
                        <div class="contentsec">
                            <p>Added 200 new items for 2 groups, Added 200 new items for
                                2 groups, Added 200 new items for 2 groups</p>
                            <div class="date">
                                <img src="../assets/images/date.png" alt="" /> 19.01.2017
                            </div>
                            <div class="time">
                                <img src="../assets/images/time.png" alt="" /> 11.12
                            </div>
                            <div class="border"></div>
                        </div>

                        <div class="contentsec" style="opacity: 0.3;">
                            <p>Added 200 new items for 2 groups, Added 200 new items for
                                2 groups, Added 200 new items for 2 groups</p>
                            <div class="date">
                                <img src="../assets/images/date.png" alt="" /> 18.01.2017
                            </div>
                            <div class="time">
                                <img src="../assets/images/time.png" alt="" /> 12.12
                            </div>
                            <div class="border"></div>
                        </div>

                        <div class="contentsec" style="opacity: 0.3;">
                            <p>Added 200 new items for 2 groups, Added 200 new items for
                                2 groups, Added 200 new items for 2 groups</p>
                            <div class="date">
                                <img src="../assets/images/date.png" alt="" /> 17.01.2017
                            </div>
                            <div class="time">
                                <img src="../assets/images/time.png" alt="" /> 09.12
                            </div>
                            <div class="border"></div>
                        </div>

                    </div>
                </div>

                <!--  Sidebar End -->

                <!--  CenterSec  -->

                <div class="col-lg-7">
                    <div class="centersec">
                        <div class="collapse" id="collapseExample">
                            <div class="card-block">
                                <h3>Add Items</h3>
                                <p>
                                    <h:form styleClass="form-group" id="uppperForm">
                                        <label>Name</label>
                                        <p:inputText styleClass="col-lg-12 input-group" />
                                        <label>Email</label>
                                        <input class="col-lg-12 input-group" />
                                        <label>Phone No</label>
                                        <p:inputText styleClass="col-lg-12 input-group" />
                                        <label>Group</label>
                                        <div class="clearfix"></div>
                                        <p:inputText styleClass="col-lg-9 input-group input1" />
                                        <p:inputText name="" type="button" value="+ Add"
                                            styleClass="col-lg-2 btn1" />
                                        <p:inputText name="" type="button" value="Add Contact"
                                            styleClass="btn editbtn btn-default" />
                                    </h:form>
                                </p>
                            </div>
                        </div>


                        <div class="additems">
                            <div class="headings yellow">
                                <h3>
                                    <a data-toggle="collapse" href="#collapseExample"
                                        aria-expanded="false" aria-controls="collapseExample">Add
                                        Items</a>
                                </h3>
                                <span>1612</span>
                            </div>
                            <div class="filter">
                                <img src="../assets/images/items.png" alt="" />
                            </div>
                            <div class="listing">
                                <h:form id="itemsListingForm">
                                    <p:dataTable rows="20" lazy="true"
                                        paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
                                        rowKey="#{item.itemId}" id="itemDetailTable"
                                        widgetVar="itemDetailTablewVar" scrollRows="20"
                                        liveScroll="true" scrollHeight="430" scrollable="true"
                                        value="#{productBean.jobLazyDataItemList}" var="item"
                                        filteredValue="#{productBean.itemModelList}"
                                        selectionMode="multiple" editable="true" editMode="cell"
                                        selection="#{productBean.selectedItemList}">
                                        <f:facet name="header">
                                            <p:outputPanel>
                                                <p:inputText id="globalFilter" styleClass="col-lg-12 search"
                                                    onkeyup="PF('itemDetailTablewVar').filter()"
                                                    placeholder="Search" />

                                            </p:outputPanel>
                                        </f:facet>
                                        <p:ajax event="cellEdit"
                                            listener="#{productController.onCellEditTableComplete(item)}"
                                            update="@([id$=itemDetailTable])" />
                                        <p:column headerText="Item Code" filterBy="#{item.itemCode}"
                                            styleClass="col-lg-2" filterStyle="display:none;">
                                            <h:outputText value="#{item.itemCode}"
                                                style="font-weight: bold" />
                                        </p:column>
                                        <p:column headerText="Item Name" filterBy="#{item.itemName}"
                                            styleClass="col-lg-8" filterStyle="display:none;">
                                            <h:outputText value="#{item.itemName}" />
                                        </p:column>
                                        <p:column headerText="Item Price" filterBy="#{item.itemPrice}"
                                            styleClass="col-lg-2" filterStyle="display:none;">
                                            <p:cellEditor>
                                                <f:facet name="output">
                                                    <h:outputText value="#{item.itemPrice}" />
                                                </f:facet>
                                                <f:facet name="input">
                                                    <p:inputText value="#{item.itemPrice}" style="width:96%" />
                                                </f:facet>
                                            </p:cellEditor>
                                        </p:column>
                                    </p:dataTable>

                                </h:form>
                            </div>
                        </div>

                        <div class="addgroup">
                            <div class="headings green">
                                <h3>Add Contact</h3>
                                <span>798</span>
                            </div>

                            <h:form id="contactListForm">
                                <div class="filter">
                                    <img src="../assets/images/groups.png" alt="" />
                                    <p:selectOneMenu value="#{productBean.selectedGroup}"
                                        styleClass="select pull-right">
                                        <f:selectItem itemLabel="Select" itemValue=""
                                            noSelectionOption="true"></f:selectItem>
                                        <f:selectItems value="#{productBean.contactGroups}"
                                            var="group" itemLabel="#{group.groupName}"
                                            itemValue="#{group.groupName}"></f:selectItems>
                                        <p:ajax listener="#{productController.filterContact}"
                                            event="change"  />
                                    </p:selectOneMenu>
                                </div>
                                <div class="listing">
                                    <p:dataTable rows="20" lazy="true"
                                        paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
                                        rowKey="#{contact.contactId}" id="contactDetailTable"
                                        widgetVar="contactDetailTablewVar" scrollRows="20"
                                        liveScroll="true" scrollHeight="430" scrollable="true"
                                        value="#{productBean.jobLazyDataContactList}" var="contact"
                                        filteredValue="#{productBean.contactModelList}"
                                        selectionMode="multiple" editable="true" editMode="cell"
                                        selection="#{productBean.selectedContactList}">
                                        <f:facet name="header">
                                            <p:outputPanel>
                                                <p:inputText id="globalFilter" styleClass="col-lg-12 search"
                                                    onkeyup="PF('contactDetailTablewVar').filter()"
                                                    placeholder="Search" />
                                            </p:outputPanel>
                                        </f:facet>
                                        <p:column headerText="Contact Name"
                                            filterBy="#{contact.contactFirstName}"
                                            filterStyle="display:none;">
                                            <h:outputText value="#{contact.contactFirstName}" />
                                            <h:outputText value="#{contact.contactSecondName}" />
                                        </p:column>
                                        <p:column headerText="Contact Number"
                                            filterBy="#{contact.contactMobile}"
                                            filterStyle="display:none;">
                                            <h:outputText value="#{contact.contactMobile}" />
                                        </p:column>
                                    </p:dataTable>
                                </div>
                            </h:form>
                        </div>
                    </div>
                </div>

                <!--  CenterSec End -->

                <!--  RighrSec  -->

                <div class="col-lg-3">
                    <div class="rightsec">
                        <textarea name="Type Your Message Here..." cols="" rows="8"
                            class="col-lg-12" placeholder="Type Your Message Here..."></textarea>
                        <p>maximum characters : 200</p>
                        <textarea name="Type Your Message Here..." cols="" rows="14"
                            class="col-lg-12" placeholder="Preview..."></textarea>
                        <input name="" type="button" value="Update"
                            class="btn updatebtn btn-default pull-right" />
                    </div>
                </div>

                <!--  RighrSec End  -->

            </div>
        </div>
        </section>

        <!--   Main End  -->

        <!--   Footer   -->

        <footer>
        <div class="col-lg-12">
            <p>&copy; Company Name. 2017</p>
        </div>

        </footer>
        <!--   Footer End  -->
    </div>


    <!--   Core JS Files   -->
    <!-- <script src="../assets/js/jquery-1.10.2.js" type="text/javascript"></script>
    <script src="../assets/js/bootstrap.min.js" type="text/javascript"></script> -->
</h:body>
</html>

错误

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

java.lang.NullPointerException
    org.primefaces.component.celleditor.CellEditorRenderer.encodeEnd(CellEditorRenderer.java:38)
    javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
    org.primefaces.component.column.Column.renderChildren(Column.java:336)
    org.primefaces.component.datatable.DataTableRenderer.encodeCell(DataTableRenderer.java:1022)
    org.primefaces.component.datatable.DataTableRenderer.encodeRow(DataTableRenderer.java:970)
    org.primefaces.component.datatable.DataTableRenderer.encodeRows(DataTableRenderer.java:878)
    org.primefaces.component.datatable.DataTableRenderer.encodeTbody(DataTableRenderer.java:825)
    org.primefaces.component.datatable.DataTableRenderer.encodeScrollBody(DataTableRenderer.java:399)
    org.primefaces.component.datatable.DataTableRenderer.encodeScrollableTable(DataTableRenderer.java:346)
    org.primefaces.component.datatable.DataTableRenderer.encodeMarkup(DataTableRenderer.java:240)
    org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:85)
    javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
    com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:424)
    com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125)
    com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
    com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    utils.AuthenticationFilter.doFilter(AuthenticationFilter.java:26)

Web.xml中

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
  <display-name>almightyenterprises</display-name>
  <welcome-file-list>
    <welcome-file>login.xhtml</welcome-file>
  </welcome-file-list> 
  <filter>
    <filter-name>AuthenticationFilter</filter-name>
    <filter-class>utils.AuthenticationFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>AuthenticationFilter</filter-name>
    <url-pattern>/secure/*</url-pattern>
  </filter-mapping>
  <context-param>
    <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>server</param-value>
  </context-param>
  <context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>resources.application</param-value>
  </context-param>
  <listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
  </listener>
  <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

  <mime-mapping>
    <extension>woff</extension>
    <mime-type>application/x-font-woff</mime-type>
  </mime-mapping>
  <mime-mapping>
    <extension>ttf</extension>
    <mime-type>application/octet-stream</mime-type>
  </mime-mapping>
  <mime-mapping>
    <extension>otf</extension>
    <mime-type>application/octet-stream</mime-type>
  </mime-mapping>
  <mime-mapping>
    <extension>png</extension>
    <mime-type>image/png</mime-type>
  </mime-mapping>
  <servlet>
    <servlet-name>jersey-serlvet</servlet-name>
    <servlet-class>
        com.sun.jersey.spi.container.servlet.ServletContainer
    </servlet-class>
    <init-param>
      <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
      <param-value>true</param-value>
    </init-param>
    <init-param>
      <param-name>com.sun.jersey.config.property.packages</param-name>
      <param-value>controller</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
        <url-pattern>*.jsf</url-pattern>
        <url-pattern>*.xhtml</url-pattern>
        <url-pattern>*.jsp</url-pattern>
    </servlet-mapping>
  <servlet-mapping>
    <servlet-name>jersey-serlvet</servlet-name>
    <url-pattern>/rest/*</url-pattern>
  </servlet-mapping>
</web-app>

在本地计算机上进行操作

enter image description here

0 个答案:

没有答案