1
resposta

Renderizar um DataTable fora do form

Preciso atualizar o dataTable "listSaldo" com base nos commandButton que ficam dentro de um outro dataTable "listaContas". Já tentei de tudo e não consigo. Inclusive o "@all"

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui">

<h:head></h:head>
<body id="pgPrincipal">

    <p:fieldset legend="saldos">
        <h:form id="frmDeposita" >
                <h:inputText value="#{contaUsuarioController.conta.saldoConta}"  />
                <h:commandButton action="#{contaUsuarioController.adcionaSaldo}" value="Depositar">
                    <f:ajax execute="frmDeposita" render="saldos frmDeposita listSaldo"></f:ajax>
                </h:commandButton>
        </h:form>
            <br></br>
        <h:form id="frmSaca">
                <h:inputText value="#{saqueController.saque.valorSaque}"  />
                <h:commandButton action="#{saqueController.realizaSaque}" value="Sacar" >
                    <f:ajax execute="frmSaca" render="saldos frmSaca listSaldo"></f:ajax>
                </h:commandButton>
        </h:form>
            <br></br>
        <h:form>
                <h:dataTable id="listSaldo" value="#{contaUsuarioController.saldo}" var="s">
                    <p:column>
                        <h:outputText value="Saldo em Conta:" />
                    </p:column>
                    <p:column>
                        <h:outputText value="#{s}" />
                     </p:column>
                </h:dataTable>
        </h:form>    
    </p:fieldset>

    <h:form id="frmContas">
        <p:fieldset legend="Cadastro de Contas">
            <h:panelGrid columns="2">

Descrição:             <h:inputText value="#{contaController.conta.descricao}">
                    </h:inputText>
Data de Vencimento: <p:calendar id="dataVencimento" pattern="dd/MM/yyyy"
                        value="#{contaController.conta.dataVencimento}">
                        <f:convertDateTime pattern="dd/MM/yyyy" timeZone="America/Sao_Paulo" />
                    </p:calendar>
Data da Emissão:      <p:calendar id="dataEmissao" pattern="dd/MM/yyyy"
                        value="#{contaController.conta.dataEmissao}">
                        <f:convertDateTime pattern="dd/MM/yyyy" timeZone="America/Sao_Paulo" />
                    </p:calendar>
Valor da Conta:     <h:inputText id="valor"    value="#{contaController.conta.valor}"> 
                    </h:inputText>

                    <h:commandButton action="#{contaController.salvar}" value="Salvar" > 
                        <f:ajax execute="frmContas" render="frmContas listaContas"></f:ajax>
                    </h:commandButton>
                    <h:commandButton rendered="#{contaController.modoEdicao}" action="#{contaController.cancelar()}" value="Cancelar" >
                        <f:ajax render="frmContas listaContas"></f:ajax>
                    </h:commandButton>
                </h:panelGrid>
        </p:fieldset>
        <br />

        <p:fieldset legend="Listagem de Contas">
            <h:dataTable style="border:1 " id="listaContas" value="#{contaController.contas}" var="c">
                <h:column>
                <f:facet name="header">Descrição</f:facet>
                #{c.descricao}
                </h:column>
                <h:column>
                <f:facet name="header">Data Vencimento</f:facet>
                <h:outputText value="#{c.dataVencimento}" >
                    <f:convertDateTime pattern="dd/MM/yyyy" timeZone="America/Sao_Paulo" />
                </h:outputText>
                </h:column>
                <h:column>
                <f:facet name="header">Data Emissão</f:facet>
                <h:outputText value="#{c.dataEmissao}" >
                    <f:convertDateTime pattern="dd/MM/yyyy" timeZone="America/Sao_Paulo" />
                </h:outputText>
                </h:column>
                <h:column>
                <f:facet name="header">Valor</f:facet>
                #{c.valor}
                </h:column>
                <h:column>
                <f:facet name="header">Status da Conta</f:facet>
                #{c.status}
                </h:column>
                <h:column>
                <f:facet name="header">Data Pagamento</f:facet>
                <h:outputText value="#{c.dataPagamento}" >
                    <f:convertDateTime pattern="dd/MM/yyyy" timeZone="America/Sao_Paulo" />
                </h:outputText>
                </h:column>
                <h:column>
                <h:commandButton action="#{contaController.deletar(c)}" value="Excluir" >
                    <f:ajax render="listSaldo"></f:ajax>
                </h:commandButton>
                </h:column>
                <h:column>
                <h:commandButton action="#{contaController.editar(c)}" value="Editar" />
                </h:column>
                <h:column>
                <h:commandButton action="#{contaController.pagar(c)}" value="Pagar" >
                    <f:ajax render="listSaldo"></f:ajax>
                </h:commandButton>
                </h:column>                
            </h:dataTable>
        </p:fieldset>    


</h:form>

</body>
</html>
1 resposta

Tenta colocar um id no form que envolve a tabela e pede para renderizar ele, como resultado do ajax.