Manipulating a dataTable JSF + PrimeFaces

0

How do I dataTable only be displayed after I click on Simulate Reply? When I load the page, dataTable logo first is already displayed, I do not even have any questions on it.

I have a Command Button :

<p:column headerText="Responder Simulado" style="width: 100px; text-align: center">
                        <p:commandButton id="responderSimulado" icon="ui-icon-check" title="Responder Simulado" update="@this :frmCadastroSimulado:exibePerguntas"
                            actionListener="#{responderSimuladoBean.recuperaSimuladoDeAcordoComCicloSelecionado}">
                            <f:param name="ciclo" value="#{ciclo.codigo}"/>
                        </p:commandButton>
</p:column>

And right away, I have a dataTable, which updates right after I click on reply.

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

                    <p:selectOneRadio id="resposta" style="width:35%"
                    value="#{resposta.respostaUsuario}">
                    <f:selectItem itemLabel="A" itemValue="A" />
                    <f:selectItem itemLabel="B" itemValue="B" />
                    <f:selectItem itemLabel="C" itemValue="C" />
                    <f:selectItem itemLabel="D" itemValue="D" />
                    <f:selectItem itemLabel="E" itemValue="E" />
                </p:selectOneRadio>

                    <h:outputText value="#{resposta.resultado}" />
                </p:column>
            </p:dataTable>
    
asked by anonymous 02.11.2015 / 02:32

1 answer

1
  

How do I get the dataTable to only be displayed after I click on Simulate Reply?

One way is to use the rendered attribute available in the datatable component (and practically all JSF components).

The attribute is given a value of type boolean and accepts the use of Expression Language .

A negative value indicates that the component will not render on the page.

In your case, you can use an expression similar to:

<p:dataTable rendered="#{not empty responderSimuladoBean.respostas}" />

There is a very good example available in showcase do Primefaces .

    
02.11.2015 / 15:34