Problem Disabling Button on Firstfaces

1

I'm trying to make a logic of making the excel export button disabled to the user by clicking the search button if the number of records is equal to zero. The problem is that the first time it works normal, but the second time the button is no longer rendered again.

<f:facet name="footer">
    <p:row>
        <p:column style="text-align: right" colspan="4">
            <p:commandButton id="bt_filtrar" value="#{lbl['BOTAO.FILTRAR']}" process="filtro" actionListener="#{propostaCartaoListBean.buscar}" update="tabela br_exportar"/>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            <p:commandButton id="bt_limpar" icon="botaoLimpar" title="#{lbl['BOTAO.LIMPAR']}"/>
            &nbsp;
            <p:commandButton id="bt_exportar" icon="botaoExcel" ajax="false" disabled="#{propostaCartaoListBean.lazyModel.rowCount == 0}" title="#{lbl['BOTAO.EXPORTAREXCEL']}">
                <p:dataExporter type="xls" target="tabela" fileName="propostaCartao" />  
            </p:commandButton>                                  
        </p:column>
    </p:row>
</f:facet>

This button is at the end of a panelGrid and above a datatable .

How do I solve this problem of missing component rendering?

    
asked by anonymous 24.02.2014 / 21:34

1 answer

1

Personal a work colleague introduced me to a workable solution to this problem.

<p:commandButton id="bt_filtrar" value="#{lbl['BOTAO.FILTRAR']}" 
    process="filtro"
    actionListener="#{propostaCartaoListBean.buscar}"
    update="tabela" oncomplete="atualizaBtnExportar()"/>

<p:commandButton id="bt_exportar" icon="botaoExcel" ajax="false" title="#{lbl['BOTAO.EXPORTAREXCEL']}" disabled="#{propostaCartaoListBean.lazyModel.rowCount == 0}">
    <p:dataExporter type="xls" target="tabela" fileName="propostaCartao" />  
</p:commandButton>

<p:remoteCommand name="atualizaBtnExportar" update="bt_exportar"/>

When using this tag p:remoteCommand it does the redirection to process what I want.

So it updates by completing the action on the filter button and calls the component.

But if a colleague knows, I think it has processing level of ajax of type, before, during and after ajax happens.

    
25.02.2014 / 15:24