Primefaces dataTable编辑nullPointerException

时间:2013-10-14 09:08:48

标签: jsf primefaces datatable

我目前有一个连接数据库的dataTable。这一切都很好,包括插入和删除。然后我尝试将编辑添加到我的dataTable中,突然间我收到以下错误:

  

SEVERE:带有路径[/ ProEJT]的上下文中Servlet [FacesServlet]的Servlet.service()使用根本原因抛出异常[null]   显示java.lang.NullPointerException       at 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)       在javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)       at org.primefaces.component.datatable.DataTableRenderer.encodeCell(DataTableRenderer.java:823)       at org.primefaces.component.datatable.DataTableRenderer.encodeRow(DataTableRenderer.java:784)       at org.primefaces.component.datatable.DataTableRenderer.encodeRows(DataTableRenderer.java:699)       at org.primefaces.component.datatable.DataTableRenderer.encodeTbody(DataTableRenderer.java:654)       at org.primefaces.component.datatable.DataTableRenderer.encodeRegularTable(DataTableRenderer.java:249)       在org.primefaces.component.datatable.DataTableRenderer.encodeMarkup(DataTableRenderer.java:211)       at org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:83)       在javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)       在javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)       在javax.faces.render.Renderer.encodeChildren(Renderer.java:168)       在javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)       在javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)       在javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)       在javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)       在com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:437)       在com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:124)       at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)       在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.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)       在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)       在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)       在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)       在org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)       在org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)       在org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)       在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)       在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)       在org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)       at org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:589)       at org.apache.tomcat.util.net.JIoEndpoint $ SocketProcessor.run(JIoEndpoint.java:310)       at java.util.concurrent.ThreadPoolExecutor $ Worker.runTask(ThreadPoolExecutor.java:886)       at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:908)       在java.lang.Thread.run(Thread.java:619)

据我所知,这并没有告诉我在我的代码中NullPointerException的来源。我尝试了一百万种不同的东西而没有运气。

我的数据表:

        <h:form id="form1">
        <p:growl id="growl" showDetail="true" life="3000"/>
        <p:dataTable id="dataTable" 
                    var="order" 
                    value="#{checkOut.orders}" 
                    ajax="true"
                    paginator="true" 
                    selection="#{checkOut.selectedOrder}"
                    selectionMode="single"
                    rowKey="#{order.id}" 
                    rows="10"  
                    sortMode="Multiple"
                    paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                    emptymessage="No orders found"  
                    rowsPerPageTemplate="5,10,15" 
                    rowStyleClass="#{(order.state == 'ERROR' ? 'error' : (order.state == 'Finished' ? 'finished' : (order.state == 'Failed' ? 'failed':(order.state == 'Paused' ? 'paused' : null ))))}"
                    editable="true"
                    editMode="row">


                <f:facet name="header">
                    Conversions
                </f:facet>

            <p:ajax event="rowEdit" listener="#{checkOut.onEdit}" update=":form:growl" />
            <p:ajax event="rowEditCancel" listener="#{checkOut.onCancel}" update=":form:growl"/>

            <p:column sortBy="#{order.id}">
                <p:cellEditor >
                    <f:facet name="Output">
                        <h:outputText value="#{order.id}"/>
                    </f:facet>
                    <f:facet name="Input">
                        <p:inputText value="#{order.id}" style="width:100%"/>
                    </f:facet>
                </p:cellEditor>
            </p:column>

            <p:column sortBy="#{order.created}" >
                <p:cellEditor >
                    <f:facet name="Output">
                        <h:outputText value="#{order.created}"/>
                    </f:facet>
                    <f:facet name="Input">
                        <p:inputText value="#{order.created}" style="width:100%"/>
                    </f:facet>
                </p:cellEditor>
            </p:column>

            <p:column sortBy="#{order.sender}" >
                <p:cellEditor >
                    <f:facet name="Output">
                        <h:outputText value="#{order.sender}"/>
                    </f:facet>
                    <f:facet name="Input">
                        <p:inputText value="#{order.sender}" style="width:100%"/>
                    </f:facet>
                </p:cellEditor>
            </p:column>

            <p:column sortBy="#{order.receiver}">
                <p:cellEditor >
                    <f:facet name="Output">
                        <h:outputText value="#{order.receiver}"/>
                    </f:facet>
                    <f:facet name="Input">
                        <p:inputText value="#{order.receiver}" style="width:100%"/>
                    </f:facet>
                </p:cellEditor>
            </p:column>

            <p:column sortBy="#{order.input}" >
                <p:cellEditor >
                    <f:facet name="Output">
                        <h:outputText value="#{order.input}"/>
                    </f:facet>
                    <f:facet name="Input">
                        <p:inputText value="#{order.input}" style="width:100%"/>
                    </f:facet>
                </p:cellEditor>
            </p:column>

            <p:column sortBy="#{order.output}">
                <p:cellEditor >
                    <f:facet name="Output">
                        <h:outputText value="#{order.output}"/>
                    </f:facet>
                    <f:facet name="Input">
                        <p:inputText value="#{order.output}" style="width:100%"/>
                    </f:facet>
                </p:cellEditor>
            </p:column>

            <p:column sortBy="#{order.state}">

                <p:cellEditor >
                    <f:facet name="Output">
                        <h:outputText value="#{order.state}"/>
                    </f:facet>
                    <f:facet name="Input">
                        <p:inputText value="#{order.state}" style="width:100%"/>
                    </f:facet>
                </p:cellEditor>
                <p:progressBar id="progressBarClient" value="#{checkOut.retrieveProgress(order.state)}" labelTemplate="{value}%" displayOnly="true"/>
            </p:column>

            <p:column >
                <p:commandLink id="btnDeleteRow" action="#{checkOut.deleteRow(order)}" update="dataTable" ajax="true">
                    <h:graphicImage value="/img/DeleteRed.png" style="align:center" width="30" height="30"/>
                </p:commandLink>
                <p:rowEditor />
            </p:column>

        </p:dataTable>
        <p:commandButton id="new" value="Create A New Order" update=":orderForm" oncomplete="newOrderDialog.show()" style="position:absolute; dataTable:10px; left:7px;"/>
        <p:commandButton id="logout" value="Log Out" update="growl" action="#{checkOut.logout}" style="position:absolute; dataTable:10px; right:10px"/>             
    </h:form>

2 个答案:

答案 0 :(得分:5)

使用输入和输入在小的情况下输出小平面;

<f:facet name="output">
</f:facet>

<f:facet name="input">
</f:facet>

答案 1 :(得分:1)

是的,有时是因为不是展示的同一个例子,在我的情况下,我的窗口使用相同的结构。

<p:cellEditor>
    <f:facet name="output"><h:outputText value="#{car.id}" /></f:facet>
    <f:facet name="input"><p:inputText id="modelInput" value="#{car.id}" style="width:96%"/></f:facet>
</p:cellEditor>