0
votes

I currently have a dataTable connecting to a database. It all worked fine including insert and delete. I then tried to add editing into my dataTable and all of a sudden I get the following error:

SEVERE: Servlet.service() for servlet [FacesServlet] in context with path [/ProEJT] threw exception [null] with root cause java.lang.NullPointerException at org.primefaces.component.celleditor.CellEditorRenderer.encodeEnd(CellEditorRenderer.java:38) at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786) at 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) at org.primefaces.component.datatable.DataTableRenderer.encodeMarkup(DataTableRenderer.java:211) at org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:83) at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786) at javax.faces.render.Renderer.encodeChildren(Renderer.java:168) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782) at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:437) at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:124) at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at 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) at java.lang.Thread.run(Thread.java:619)

As far as I can tell, this does not tell me where the NullPointerException comes from in my code. I have tried what feels like a million different things with no luck.

My dataTable:

        <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
Just have a look at this and find the difference with your code.Xtreme Biker
I used the Show Case row edit example to create the editing and have had another look through it and cannot see any differencesDaRoGa
I don't think you did this code based in the showcase. I had a general look to it (for 30 secs) and saw an important difference which can cause the error. Just have a look to it and you'll notice. By the way, dataTable doesn't have ajax attribute as far as I know.Xtreme Biker
I have a suggestion for you. Instead of looking for differences, do a backup of the file you posted. Then copy-paste the showcase code and start adapting it to your code, till it works. You've a lot of mess in your table, just start from a basic one and add everything you need when it's working.Xtreme Biker
I did start from a basic one and added each little thing bit by bit and got each working before I started the next one. What mess are you talking about? Is there unnecessary elements to it or just a lot of things?DaRoGa

2 Answers

6
votes

Use input & output facet in small cases;

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

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

Yes sometimes is because is not the same example of the showcase, in my case use the same structure for my window.

<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>