0

Estou tentando editar uma célula no meu data Table e recebo erro. segue o meu bean :

@Named
@ViewScoped
public class PesquisaPrevisaoBean implements Serializable {
private static final long serialVersionUID = 1L;

@Inject
private Historicos previsoes;

private List<Historico> listaDePrevisoes;

private Historico previsaoSelecionada;

private PrevisaoLazyList lazyPrevisoes;

public List<Historico> getPrevisoes() {
    return listaDePrevisoes;
}

public void inicializar() {
    // carregarListaHistoricos();
    lazyPrevisoes = new PrevisaoLazyList(previsoes);

}

public void onCellEdit(CellEditEvent event) {
    Object oldValue = event.getOldValue();
    Object newValue = event.getNewValue();

    if (newValue != null && !newValue.equals(oldValue)) {
        FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Cell Changed",
                "Old: " + oldValue + ", New:" + newValue);
        FacesContext.getCurrentInstance().addMessage(null, msg);
    }
}

Segue a view:

<p:column headerText=" Previsão1"style="text-align: center; width: 140px">
    <p:cellEditor>
      <h:outputText value="#{historico.produto.quantidadeRecente}">
      </h:outputText>
    </p:cellEditor>
</p:column>`

Segue o Stacktrace:

2017-05-19 18:45:53,035 ERROR [br.com.previsao.util.jsf.JsfExceptionHandler] Erro de sistema: null java.lang.NullPointerException at org.primefaces.component.celleditor.CellEditorRenderer.encodeEnd(CellEditorRenderer.java:38) at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:881) 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:808) at org.primefaces.component.datatable.DataTableRenderer.encodeRow(DataTableRenderer.java:773) at org.primefaces.component.datatable.DataTableRenderer.encodeTbody(DataTableRenderer.java:651) at org.primefaces.component.datatable.DataTableRenderer.encodeRegularTable(DataTableRenderer.java:234) at org.primefaces.component.datatable.DataTableRenderer.encodeMarkup(DataTableRenderer.java:196) at org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:82) at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:881) 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:851) 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:439) at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:124) at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:286) at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:286) 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:230) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:96) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Unknown Source)

2
  • Você tá chamando esse método dentro de um p:ajax? 19/05/2017 às 23:41
  • dentro de um lazy datamodel 22/05/2017 às 13:19

1 Resposta 1

0

Diferencia os facet de input e output. Ex:

<f:facet name="output">
    <h:outputText value="#{historico.produto.quantidadeRecente}"/>
</f:facet>
<f:facet name="input">
    <p:inputText value="#{historico.produto.quantidadeRecente}"/>
</f:facet>

E utilize RowEditEvent
public void onCellEdit(RowEditEvent event) { Object oldValue = event.getOldValue(); Object newValue = event.getNewValue(); if (newValue != null && !newValue.equals(oldValue)) { FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Cell Changed", "Old: " + oldValue + ", New:" + newValue); FacesContext.getCurrentInstance().addMessage(null, msg); } }

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .