cellEditor of the first faces giving error

Asked

Viewed 78 times

0

I am trying to edit a cell in my data table and get error. follow my 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);
    }
}

Follow the 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>`

Follow the Stacktrace:

2017-05-19 18:45:53,035 ERROR [br.com.previsao.util.jsf.Jsfexceptionhandler] System error: 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) 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) with.sun.faces.lifecycle.Renderresponsephase.execute(Renderresponsephase.java:120))

  • You are calling this method within a p:ajax?

  • within a datamodel Lazy

1 answer

0

Differentiates Facet from input and 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>

And use 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); } }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.