Problems retrieving the Datatable object in P:Dialog

Asked

Viewed 25 times

1

I have a datatable that lists all the students, and I have a button that opens a modal, in this modal I want to continue manipulating my datatable object, for this I use the propriedadef:setPropertyActionListener, but the object always comes empty, I’ve looked at several topics here on the forum but nothing solved, if someone can give a north I thank;

There in the dialog the attribute ID always comes zero, there’s my problem but I can’t find why.

Bean

@ManagedBean(name = "funcionarioMB")
@SessionScoped
public class FuncionarioMB {

private Aluno aluno;
private List<Aluno> alunosInativos;
private FuncionarioDAO fDAO = new FuncionarioDAO();

//getters and setters


//construtor
public FuncionarioMB() {
        aluno = new Aluno();
        alunosInativos = fDAO.ListarAlunosInativos();
}

//Tela

        <h:form id="form" prependId="false">
        <p:dataTable var="aluno" value="#{funcionarioMB.alunosInativos}">

             .... OUTRAS COLUNAS....

            <div class="ui-g-12">
            <p:column style="width:60px">
           <p:commandButton value="Recusar" update="confirmaRecusa" oncomplete="PF('confirmaRecusa').show()" styleClass="btn btn-danger btn-block" >
            <f:setPropertyActionListener value="#{aluno}" target="#{funcionarioMB.aluno}" />
             </p:commandButton>
            </p:column>
            </div>
            </p:dataTable>

//Dialog

<p:dialog header="Motivo" widgetVar="confirmaRecusa" modal="true" id="confirmaRecusa" height="200" width="200">
<p:inputText id="email" maxlength="200" value="#{funcionarioMB.email.assunto}" styleClass="form-control" required="true" requiredMessage="Necessário informar um motivo" />
<h:outputText value="#{funcionarioMB.aluno.id}" />
<p:commandButton value="Aceitar" id="aceitar" action="#{funcionarioMB.recusarAluno(aluno)}" styleClass="btn btn-success btn-block" ajax="false" />
</p:dialog></h:form>`
  • Try to do this: <p:commandButton value="Recusar" action="#{funcionarioMB.setAluno(aluno)}" update="confirmaRecusa" oncomplete="PF('confirmaRecusa').show()" styleClass="btn btn-danger btn-block" />. Something else, I think action="#{funcionarioMB.recusarAluno(aluno)}" will not work and nor need to pass student as parameter because the student is already set in functionMB.

No answers

Browser other questions tagged

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