Rendered does not work on dataTable

0

Good afternoon.

I have a simple problem. However, I have difficulty solving it. I have these 2 methods to control my Rendered from 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 this boolean method, which 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>

Simulate generate button code:

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

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

    
asked by anonymous 09.11.2015 / 21:26

1 answer

1

You are sending the button updating the dataTable "DisplayQuestions", except that this datatable has a rendered. So, if there is nothing to show, this datatable does not exist and the button does not have what to update.

Change the button update="" to some other containter that has not rendered. Or for the @form itself if it and the table are on the same form.

Also check that the questions were actually generated.

    
09.11.2015 / 21:46