Jsf f:setPropertyActionListener始终设置null

Jsf f:setPropertyActionListener始终设置null,jsf,facelets,Jsf,Facelets,我试图使用将当前迭代的作为托管bean的属性。但是,它始终设置为null 视图,dentistas.xhtml: <!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="ht

我试图使用
将当前迭代的
作为托管bean的属性。但是,它始终设置为
null

视图,
dentistas.xhtml

<!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://java.sun.com/jsf/html"  
    xmlns:f="http://java.sun.com/jsf/core"  
    xmlns:ui="http://java.sun.com/jsf/facelets"  
    xmlns:p="http://primefaces.org/ui">  

<h:head>  

</h:head>  
<h:body>  
    <ui:composition template="/templates/template.xhtml">  

        <ui:define name="content">  
            <h:form id="formDentistas">  

                <p:growl autoUpdate="true" />  

                <p:commandButton icon="ui-icon-plus" value="Cadastrar"  
                    id="cadastrar" oncomplete="dialogCadastrar.show()" />  


                <p:dataTable var="dentista" value="#{dentistaMB.dentistas}"  
                    paginator="true" emptyMessage="Não foi encontrado nenhum registro"  
                    rows="10" id="dataTableDentistas">  

                    <f:facet name="header">Lista de Dentistas</f:facet>  
                    <p:column headerText="Nome" sortBy="nome" filterBy="nome" id="nome"  
                        width="200px">  
                    #{dentista.pessoaFisica.nome}  
                </p:column>  

                    <p:column headerText="Data Nascimento" sortBy="dataNascimento"  
                        filterBy="dataNascimento" id="dataNascimento" width="60px">  
                    #{dentista.pessoaFisica.dataNascimento}  
                </p:column>  

                    <p:column headerText="CRO" sortBy="cro" filterBy="cro" id="cro"  
                        width="60px">  
                    #{dentista.cro}  
                </p:column>  

                    <p:column headerText="Ações" style="width:50px;">  
                        <p:commandButton value="Alterar" icon="ui-icon-pencil">  
                           <f:setPropertyActionListener target="#{dentistaMB.selectedDentista}" value="#{dentista}" />                                  
                        </p:commandButton>  

                        <p:commandButton value="Remover" icon="ui-icon-trash"  
                            actionListener="#{dentistaMB.deletar}">  
                            <f:setPropertyActionListener target="#{dentistaMB.selectedDentista}" value="#{dentista}" />  
                        </p:commandButton>  
                    </p:column>  

                </p:dataTable>  
            </h:form>  

            <ui:include src="/tabelas/dialog_insert_dentista.xhtml" />  


        </ui:define>  
    </ui:composition>  


</h:body>  
</html>  
这里,

不要忘记删除
ActionEvent
参数:

public void deletar() {  
    // ...
}
另见:

与具体问题无关,如果您恰好针对与Servlet 3.0/EL 2.2兼容的容器,那么您甚至可以完全摆脱该

<p:commandButton value="Remover" icon="ui-icon-trash"  
    action="#{dentistaMB.deletar(dentista)}" />

另见

非常好的第3点。我的问题解决了。非常感谢。这是有史以来最好的答案,为什么propertyactionlistener的破解是空的!!值得一提的是,你应该因为拥有如此深刻的JSF知识而获得诺贝尔奖。
<p:commandButton value="Remover" icon="ui-icon-trash"  
    action="#{dentistaMB.deletar}">  
    <f:setPropertyActionListener target="#{dentistaMB.selectedDentista}" value="#{dentista}" />  
</p:commandButton>  
public void deletar() {  
    // ...
}
<p:commandButton value="Remover" icon="ui-icon-trash"  
    action="#{dentistaMB.deletar(dentista)}" />
public void deletar(Dentista selectedDentista) {  
    // ...
}