Estou tentando excluir um item da tabela. eu abro um p:Dialog e la tem um botão que deleto, mas quando tento deletar apresenta erro dizendo que a entidade esta null.
ago 27, 2017 10:52:13 PM com.sun.faces.lifecycle.ApplyRequestValuesPhase execute
ADVERTÊNCIA: #{pessoaBean.Remove}: java.lang.IllegalArgumentException: attempt to create delete event with null entity
javax.faces.FacesException: #{pessoaBean.Remove}: java.lang.IllegalArgumentException: attempt to create delete event with null entity
Trecho do Bean
public String Remove() {
this.objRb.Remove(this.pessoa);
return "";
}
Pagina
<?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:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Título da página (seção head necessária ao Primefaces)</title>
</h:head>
<h:body>
<p:layout fullPage="true">
<p:layoutUnit position="north" size="100">
teste
</p:layoutUnit>
<p:layoutUnit position="west" resizable="false" size="245" >
<h:form >
<p:menu />
<h3>Toggleable</h3>
<p:menu toggleable="true">
<p:submenu label="Ajax">
<p:menuitem value="Save" icon="ui-icon-disk" />
<p:menuitem value="Update" icon="ui-icon-arrowrefresh-1-w"/>
</p:submenu>
<p:submenu label="Non-Ajax">
<p:menuitem value="Delete" ajax="false" icon="ui-icon-close"/>
</p:submenu>
<p:submenu label="Navigations">
<p:menuitem value="External" url="http://www.primefaces.org" icon="ui-icon-home"/>
</p:submenu>
</p:menu>
</h:form >
</p:layoutUnit>
<p:layoutUnit position="center">
<h:form id="teste">
<p:growl id="msgs" showDetail="true" />
<legend>Dados Pessoa</legend>
<h:panelGrid>
<h:outputLabel value = "Nome:" for="Nome" />
<h:inputText id="Nome" value = "#{pessoaBean.pessoa.nome}"/>
<h:outputLabel value = "Mae:" for="Mae" />
<h:inputText id="Mae"/>
<h:outputLabel value = "Pai:" for="Pai" />
<h:inputText id="Pai"/>
<p:commandButton value="Salvar" action="#{pessoaBean.gravar}" update="@form" process="@form" />
</h:panelGrid>
<h:panelGrid columns="3">
<p:inputText value="#{pessoaBean.filtro.descricao}" id="descricao"/>
<p:commandButton value="Consultar" update="tablePessoa" process="@form" />
</h:panelGrid>
<p:dataTable id="tablePessoa" var="pessoa" value="#{pessoaBean.model}" rows="5" lazy="true"
paginator="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,15" currentPageReportTemplate="Página: {currentPage} de {totalPages} " >
<p:column headerText="nome">
<h:outputText value="#{pessoa.nome}" />
</p:column>
<p:column style="width:32px;text-align: center">
<p:commandButton update="form:carDetail" oncomplete="PF('carDialog').show()" icon="ui-icon-search" title="View" >
<f:setPropertyActionListener value="#{pessoa}" target="#{pessoaBean.pessoa}" />
</p:commandButton>
</p:column>
</p:dataTable>
</h:form>
</p:layoutUnit>
</p:layout>
<h:form id="form">
<p:dialog header="Car Info" widgetVar="carDialog" modal="true" showEffect="fade" hideEffect="fade" resizable="false">
<p:outputPanel id="carDetail" style="text-align:center;">
<p:panelGrid columns="2" rendered="#{not empty pessoaBean.pessoa}" columnClasses="value">
<f:facet name="header">
</f:facet>
<h:outputText value="Nome:" />
<h:outputText value="#{pessoaBean.pessoa.nome}" />
</p:panelGrid>
</p:outputPanel>
<p:growl id="growl" life="2000" />
<h:commandLink action="#{pessoaBean.Remove}" immediate="true">
<h:outputText value="Delete" />
<f:setPropertyActionListener value="#{pessoa}" target="#{pessoaBean.pessoa}" />
<p:ajax update="teste:tablePessoa"/>
</h:commandLink>
</p:dialog>
</h:form>
</h:body>
</html>