Rendered Does not work in datatable

Asked

Viewed 161 times

0

Good afternoon.

I have a simple problem. However, I am struggling to solve. I have these 2 methods to control my Rendered do dataTable:

// Filtra o simulado..
    @Transactional
    public void gerarSimulado() {
        this.questoes = simuladoFiltroDAO.geraSimuladoPorFiltro(
                cursoSelecionado.getCodigo(), this.complexidadeSelecionada,
                this.numeroDeQuestoesSimulado);
        isMostraQuestoesGeradasSimulado();
        this.simulado.setNumeroQuestoesSimulado(numeroDeQuestoesSimulado);
        this.simulado.setCurso(cursoSelecionado);
        this.simulado.setQuestoes(questoes);

    }

In particular that method boolean, that controls the rendered:

public boolean isMostraQuestoesGeradasSimulado() {
            return this.questoes != null;
        }

On my xhtml page, I have:

    <p:dataTable id="exibePerguntas" rendered="#{gerarSimuladoBean.mostraQuestoesGeradasSimulado}" var="questao" paginator="true"
                            rowsPerPageTemplate="2,3,5,10,12" paginatorPosition="bottom" value="#{gerarSimuladoBean.questoes}">
            <p:column headerText="Perguntas">
                        <br></br>
                        <h:outputText escape="false" value="#{questao.pergunta}"  />
            </p:column>
</p:dataTable>

Simulated generate button code:

 <p:commandButton id="geraSimulado" value="Gerar Simulado" action="#{gerarSimuladoBean.gerarSimulado}" 
                    icon="ui-icon-search" update="@this exibePerguntas">
                </p:commandButton>

By logic, when clicking on the button "generate simulated", it is already to appear the questions right? Since the questions will be populated and the result will give true. Only that’s not what’s happening. Does anyone know why?

  • put the button code there. Please.

  • @Rafaeltscs the code of the simulated Generate button is the public void method gerarSimulado(). The method is above!

  • phallus of JSF (HTML)

  • All right, I’ll put.

  • @Rafaeltscs ta aí mano.

1 answer

1


You are sending the button to update the datatable "exibePerguntas", only that this datatable has a rendered. So, if there is nothing to show, this datatable does not exist and the button has no current.

Change the update="" from the button to some other account that has no rendered. Or to @form itself if it and the table are in the same form.

also check if the questions were actually generated.

  • 1

    believe me Rafaeltscs worked well. I changed the update to @form and went.

Browser other questions tagged

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