[RESOLVIDO] Problema com Dialog (JSF - PrimeFaces e Ajax)

Galera, seguinte…
Tenho uma Dialog que é chamada na ação de um botão.
Essa Dialog deve exibir os dados num DataTable conforme o código abaixo:

	<p:dialog header="Dados das Estações" widgetVar="descargas"
		modal="true" showEffect="slide" width="800" height="600"
		onShow="mymap.checkResize()">
		<h:form id="teste">
			<p:dataTable id="tabelaDesc" var="descarga"
				value="#{mapController.listaResumo}" paginator="true" rows="10">
				<p:column>
					<f:facet name="header">
						<h:outputText value="Estação" />
					</f:facet>
					<h:outputText value="#{descarga.estacaoCodigo}" />
				</p:column>
				<p:column>
					<f:facet name="header">
						<h:outputText value="Data" />
					</f:facet>
					<h:outputText value="#{descarga.data}" />
				</p:column>
				<p:column>
					<f:facet name="header">
						<h:outputText value="Cota" />
					</f:facet>
					<h:outputText value="#{descarga.cota}" />
				</p:column>
				<p:column>
					<f:facet name="header">
						<h:outputText value="Vazão" />
					</f:facet>
					<h:outputText value="#{descarga.vazao}" />
				</p:column>
			</p:dataTable>
			<p:panel header="Exportar Dados">
				<h:commandLink>
					<p:graphicImage value="/img/excel.png" />
					<p:dataExporter type="xls" target="tabelaDesc"
						fileName="xlsResumos" />
				</h:commandLink>
			</p:panel>
		</h:form>
	</p:dialog>

Porém quando ele abre o Dialog as informações não são exibidas.
Minha #{mapController.listaResumo} retorna o DataModel preenchido. Porém não exibe.
Se eu submeter a página e clicar para exibir o Dialog novamente ele exibe os dados…

Alguma idéia do que fazer??

Vlw

Você está lembrando de atribuir o botão que invoca o Dialog com um “update”?

Na verdade o dialog eh chamado dentro de um menuitem…
e realmente não coloquei update. Como ficaria?

<p:menuitem value="Descarga" action="#{mapController.exibirDescargas}" oncomplete="descargas.show()" />

aonde vc esta atualizando (update = “dialog”) ?

Basta apontar o atribuir ao update o id do seu componente Dialog:

   1. <p:menuitem value="Descarga" action="#{mapController.exibirDescargas}" oncomplete="descargas.show()"  update="ID_DO_DIALOG"/>  

Olha como está meu Dialog:

	<p:dialog header="Dados das Estações" widgetVar="dlgDescargas"
		modal="true" showEffect="slide" width="800" height="600"
		onShow="mymap.checkResize()">

tenho que colocar update=“dlgDescargas” ???

Ou eu posso simplesmente dar update no meu DataTable???

Olá caputojf1!

Já tive um problema com Dialog e Datatable do primefaces na versão 1.1
Veja se é o mesmo problema: http://www.guj.com.br/java/221055-primefaces-erro-com-pdatatable-em-um-pdialog-resolvido

tem que colocar

"tenho que colocar update=“dlgDescargas”?? "

Sim, mais no menu

adiciona um id no dialog e tenta de novo.

    <p:dialog header="Dados das Estações" widgetVar="dlgDescargas"  
        modal="true" showEffect="slide" width="800" height="600"  
        onShow="mymap.checkResize()" id="teste">  


update="teste"

Resolvi, eu posso dar update somente no meu DataTable sim.

Vlw pela força

Olá Pessoas, boa tarde,

estou com problema parecido, no meu caso, o dialog nem chega a ser exibido. Não sei se é o meu commandButton que está chamando de forma errada ou se é a codificação do dialog que está errada. Meu sistema está baseado num exemplo que peguei num blog.

Por favor me ajudem, estou iniciando em Java. Uso Tomcat 6, JDK 1.6 e PrimeFaces 5. Obrigado antecipadamente.

package controller;

import dao.ImovelDao;

import java.io.Serializable;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;




import model.Imovel;

@ManagedBean @ViewScoped
public class ImovelBean implements Serializable {
	private ImovelDao imovelDao;
	private Imovel imovel = new Imovel();
	private DataModel<Imovel> imoveis;

	public void novo() {
		imovel = new Imovel();
	}

	public String inserir() {
		String resultado = "falha";
		imovelDao = new ImovelDao();
		boolean retorno = imovelDao.inserir(imovel);

		if (retorno) {
			resultado = "imoveis";
		}

		return resultado;
	}

	public void selecionar() {
		imovel = imoveis.getRowData();
	}

	public String alterar() {
		String resultado = "falha";
		imovelDao = new ImovelDao();
		boolean retorno = imovelDao.alterar(imovel);

		if (retorno) {
			resultado = "imoveis";
		}

		return resultado;
	}

	public String remover() {
		String resultado = "falha";
		imovelDao = new ImovelDao();
		boolean retorno = imovelDao.remover(imovel);

		if (retorno) {
			resultado = "imoveis";
		}

		return resultado;
	}

	public DataModel<Imovel> consultar() {
		imovelDao = new ImovelDao();
		List<Imovel> imovelList = imovelDao.listar();
		imoveis = new ListDataModel<Imovel>(imovelList);
		return imoveis;
	}
	
	public Imovel getImovel() {
		return imovel;
	}
	
	public void setImovel(Imovel imovel) {
		this.imovel = imovel;
	}

	public DataModel<Imovel> getImoveis() {
		imovelDao = new ImovelDao();
		List<Imovel> imovelList = imovelDao.listar();
		imoveis = new ListDataModel<Imovel>(imovelList);
		return imoveis;
	}

	public void setImoveis(DataModel<Imovel> imoveis) {
		this.imoveis = imoveis;
	}
}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://xmlns.jcp.org/jsf/core"
	xmlns:h="http://xmlns.jcp.org/jsf/html"
	xmlns:p="http://primefaces.org/ui">

<h:head>
	<title>Gerenciar Imóveis</title>
</h:head>
<h:body>
	<div align="center">
		<h:form id="formPrincipal">

			<p:dataTable id="tabelaImoveis" value="#{imovelBean.imoveis}" var="lista" style="width:70%">
				<f:facet name="header">Gerenciador de Imóveis</f:facet>
				<p:column headerText="Matrícula">
					<h:outputText value="#{lista.matriculaImovel}" />
				</p:column>
				<p:column headerText="Endereço">
					<h:outputText value="#{lista.enderecoImovel}" />
				</p:column>
				<p:column headerText="Valor do Imóvel">
					<h:outputText value="#{lista.valorImovel}">
						<f:convertNumber type="currency" locale="pt_BR" />
					</h:outputText>
				</p:column>
				<p:column headerText="Ações">
					<p:commandButton value="Alterar" update=":formAlterar:Alterar"
						onclick="Alterar.show();">
					</p:commandButton>
					<p:commandButton value="Excluir" update=":formExcluir:Excluir"
						oncomplete="confirmation.show()">
						
						<f:setPropertyActionListener target="#{imovelBean.selecionar.imovel}"
							value="#{lista}" />
					</p:commandButton>
				</p:column>

			</p:dataTable>
			<p:commandButton value="Cadastrar" id="cadastrar"
				oncomplete="dialogCadastrar.show()" />
		</h:form>
	</div>
	<h:form id="formAlterar">
		<p:dialog header="Alterar Registro" widgetVar="dialogAlterar" modal="true" id="Alterar">
			<p:panelGrid id="panelAlterar" columns="2">
				<h:outputText value="Matrícula" />
				<p:inputText value="#{imovelBean.imovel.matriculaImovel}" />
				<h:outputText value="Endereço:" />
				<p:inputText value="#{imovelBean.imovel.enderecoImovel}" />
				<h:outputText value="Valor:" />
				<p:inputText value="#{imovelBean.imovel.valorImovel}" />
			</p:panelGrid>
			<p:commandButton value="Alterar"
				actionListener="#{imovelBean.alterar}"
				update=":formPrincipal:tabelaImoveis"
				oncomplete="dialogAlterar.hide()" />
		</p:dialog>
	</h:form>
	<h:form id="formCadastrar">
		<p:dialog header="Novo Cadastro" widgetVar="dialogCadastrar" modal="true">
			<p:panelGrid columns="2">
				<p:outputLabel value="Matrícula" />
				<p:inputText size="8" value="#{imovelBean.imovel.matriculaImovel}" />
				<p:outputLabel value="Endereço" />
				<p:inputText size="60" value="#{imovelBean.imovel.enderecoImovel}" />
				<p:outputLabel value="Valor" />
				<p:inputText size="10" value="#{imovelBean.imovel.valorImovel}" />
				<h:commandButton value="Cadastrar" action="#{imovelBean.inserir}" />
			</p:panelGrid>
			<p:commandButton value="Cadastrar" action="#{imovelBean.inserir}"
				update=":formPrincipal:tabelaImoveis" oncomplete="dialogCadastrar.hide()" />
		</p:dialog>
	</h:form>
	<h:form id="formExcluir">
		<p:confirmDialog id="Excluir"
			message="Confirma exclusão do imóvel de matrícula #{imovelBean.imovel.matriculaImovel}?"
			header="Excluir" severity="alert" widgetVar="confirmation">
			
			<p:commandButton id="confirm" value="Sim"
				oncomplete="confirmation.hide()"
				actionListener="#{imovelBean.excluir}"
				update=":formPrincipal:tabelaImoveis" />
			<p:commandButton id="decline" value="Não"
				onclick="confirmation.hide()" type="button" />
		</p:confirmDialog>
	</h:form>
</h:body>
</html>