Problemas ao carregar dados no JSF e PrimeFaces

11 respostas
R

Ola,

Meu problema é o seguinte, tenho uma tabela com alguns dados e um botão para alterar esses dados, quando clico no botão não vem nenhuma informação para alterar, nem chega a bater no meu bean, alias nenhum botão bate no bean.

Vou postar o código dos dois

JSF

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui" xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
	<style>
#menu .currentClientes a {
	background: #950D08;
	color: #FFFFFF;
}
</style>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title></title>
	<meta name="keywords" content="" />
	<meta name="description" content="" />
	<link href="http://fonts.googleapis.com/css?family=Oswald" rel="stylesheet" type="text/css" />
	<link href="css/default.css" rel="stylesheet" type="text/css" media="all" />
	<!--[if IE 6]>
<link href="default_ie6.css" rel="stylesheet" type="text/css" />
<![endif]-->
</h:head>
<h:body>
	<div id="welcome">
		<h2 class="title">
			<a href="#">Clientes</a>
		</h2>
		<div class="content">
			<h:form id="form">
				<p:growl id="growl" showDetail="true" sticky="false" />
				<p:dataTable id="tabela" value="#{clientBean.clients}" var="clie" emptyMessage="Nenhum registro encontrado." paginator="true" rows="10">
					<f:facet name="header">  
                    		Lista de Clientes&nbsp;&nbsp; - &nbsp;&nbsp;Total:&nbsp;#{clientBean.totalClients}
               		</f:facet>

					<p:column headerText="Nome" sortBy="#{clie.name}" filterBy="#{clie.name}" style="text-align: center; width:10%; font: 16px Arial;">
						<h:outputText value="#{clie.name}" styleClass="dataStyle" />
					</p:column>
					
					<p:column headerText="Telefone" sortBy="#{clie.phone}" filterBy="#{clie.phone}" style="text-align: center; width:10%; font: 16px Arial;">
						<h:outputText value="#{clie.phone}" styleClass="dataStyle" />
					</p:column>
					
					<p:column headerText="E-mail" sortBy="#{clie.mail}" filterBy="#{clie.mail}" style="text-align: center; width:10%; font: 16px Arial;">
						<h:outputText value="#{clie.mail}" styleClass="dataStyle" />
					</p:column>
					
					<p:column headerText="Cidade" sortBy="#{clie.city}" filterBy="#{clie.city}" style="text-align: center; width:10%; font: 16px Arial;">
						<h:outputText value="#{clie.city}" styleClass="dataStyle" />
					</p:column>

					<p:column style="text-align: center; width:15%">
						<p:commandButton id="alterButton" update=":form:displayEdit" oncomplete="cliAlterDialog.show()" icon="ui-icon-pencil" title="Editar" style="width:30%">
							<f:setPropertyActionListener value="#{clie}" target="#{clientBean.selectClient}" />
						</p:commandButton>
						<p:commandButton id="olharButton" oncomplete="descClienteDialog.show()" icon="ui-icon-pencil" title="Detalhes" style="width:30%">
							<f:setPropertyActionListener value="#{clie}" target="#{clientBean.selectClient}" />
						</p:commandButton>
						<p:commandButton icon="ui-icon-trash" onclick="confirmation.show()" style="width:30%">
							<f:setPropertyActionListener value="#{clie}" target="#{clientBean.request}" />
						</p:commandButton>
					</p:column>

					<f:facet name="footer">
						<p:commandButton id="insertButton" value="Inserir" icon="ui-icon-pencil" update=":form:tabela" oncomplete="cliInsertDialog.show()" />
					</f:facet>

				</p:dataTable>

				<p:dialog header="Alterar Client" widgetVar="cliAlterDialog" resizable="false" id="cliAlterDialog" showEffect="fade" hideEffect="explode" modal="true">

					<h:panelGrid id="displayEdit" columns="2" cellpadding="4" style="margin:0 auto;">

						<h:outputLabel value="Nome:*" for="nameAlter" />
						<p:inputText id="nameAlter" required="true" value="#{clientBean.selectClient.name}" style="font-size: 12px;"/>

						<h:outputLabel value="Cpf:*" for="cpfAlter" />
						<p:inputText id="cpfAlter" required="true" value="#{clientBean.selectClient.cpf}" style="font-size: 12px;"/>

						<h:outputLabel value="Telefone:*" for="phoneAlter" />
						<p:inputText id="phoneAlter" required="true" value="#{clientBean.selectClient.phone}" style="font-size: 12px;"/>

						<h:outputLabel value="E-mail:*" for="mailAlter" />
						<p:inputText id="mailAlter" required="true" value="#{clientBean.selectClient.mail}" style="font-size: 12px;"/>

						<h:outputLabel value="Cidade:*" for="cityAlter" />
						<p:inputText id="cityAlter" required="true" value="#{clientBean.selectClient.city}" style="font-size: 12px;"/>

						<h:outputLabel value="Estado:" for="stateAlter" />
						<p:selectOneMenu id="stateAlter" value="#{clientBean.selectClient.state}" effect="highlight" style="font-size: 12px;">
							<f:selectItem itemLabel="Selecione.." itemValue="" />
							<f:selectItems value="#{clientBean.stateList}" />
						</p:selectOneMenu>

						<h:outputLabel value="Endereço:*" for="addressAlter" />
						<p:inputText id="addressAlter" required="true" value="#{clientBean.selectClient.address}" style="font-size: 12px;"/>

						<h:outputLabel value="Cep:*" for="cepAlter" />
						<p:inputText id="cepAlter" required="true" value="#{clientBean.selectClient.cep}" style="font-size: 12px;"/>

						<p:commandButton update="tabela" oncomplete="cliAlterDialog.hide();" actionListener="#{clientBean.edit}" value="Salvar" />

					</h:panelGrid>

				</p:dialog>

				<p:dialog header="Incluir Cliente" widgetVar="cliInsertDialog" resizable="false" id="cliInsertDialog" showEffect="fade" hideEffect="explode" modal="true">

					<h:panelGrid id="displaySave" columns="2" cellpadding="4" style="margin:0 auto;">

						<h:outputLabel value="Nome:*" for="nameInsert" />
						<p:inputText id="nameInsert" required="true" value="#{clientBean.client.name}" style="font-size: 12px;"/>

						<h:outputLabel value="Cpf:*" for="cpfInsert" />
						<p:inputText id="cpfInsert" required="true" value="#{clientBean.client.cpf}" style="font-size: 12px;"/>

						<h:outputLabel value="Telefone:*" for="phoneInsert" />
						<p:inputText id="phoneInsert" required="true" value="#{clientBean.client.phone}" style="font-size: 12px;"/>

						<h:outputLabel value="E-mail:*" for="mailInsert" />
						<p:inputText id="mailInsert" required="true" value="#{clientBean.client.mail}" style="font-size: 12px;"/>

						<h:outputLabel value="Cidade:*" for="cityInsert" />
						<p:inputText id="cityInsert" required="true" value="#{clientBean.client.city}" style="font-size: 12px;"/>

						<h:outputLabel value="Estado:" for="stateInsert" />
						<p:selectOneMenu id="stateInsert" value="#{clientBean.client.state}" effect="highlight" style="font-size: 12px;">
							<f:selectItem itemLabel="Selecione.." itemValue="" />
							<f:selectItems value="#{clientBean.stateList}" />
						</p:selectOneMenu>

						<h:outputLabel value="Endereço:*" for="addressInsert" />
						<p:inputText id="addressInsert" required="true" value="#{clientBean.client.address}" style="font-size: 12px;"/>

						<h:outputLabel value="Cep:*" for="cepInsert" />
						<p:inputText id="cepInsert" required="true" value="#{clientBean.client.cep}" style="font-size: 12px;"/>
						
						<p:commandButton id="saveBtn" update=":form:tabela" actionListener="#{clientBean.save}" oncomplete="cliInsertDialog.hide();" value="Salvar" />

					</h:panelGrid>

				</p:dialog>

				<p:dialog header="Dados do Cliente" widgetVar="descClienteDialog" resizable="false" id="descClienteDialog" showEffect="fade" hideEffect="explode" modal="true">
					<p:outputPanel id="panel" autoUpdate="true">
						<h:outputLabel value="Nome:" for="nameLook" />
						<h:outputText id="nameLook" value="#{clientBean.selectClient.name}" style="font-size: 12px;" />
					</p:outputPanel>
				</p:dialog>

				<p:confirmDialog message="Deseja realmente excluir este registro?" hideEffect="explode" header="Aviso" severity="alert" widgetVar="confirmation" modal="true">
					<p:commandButton id="btnSim" value="Sim" oncomplete="confirmation.hide();" actionListener="#{clientBean.delete}" process="@form" update=":form:tabela" />
					<p:commandButton id="btnNao" value="Não" onclick="confirmation.hide();" type="button" />
				</p:confirmDialog>
			</h:form>
		</div>
	</div>
</h:body>
</html>

Bean

package br.com.beans;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

import org.apache.log4j.Logger;
import org.primefaces.event.SelectEvent;
import org.primefaces.event.UnselectEvent;

import br.com.dao.ClientDao;
import br.com.dao.ClientDaoImpl;
import br.com.models.Client;
import br.com.utils.CheckCpf;
import br.com.utils.Utils;

@ManagedBean
@SessionScoped
public class ClientBean implements Serializable {


	private static final long serialVersionUID = 1L;
	private Logger logger = Logger.getLogger(getClass());
	private Client client = new Client();
	private List<Client> clients = new ArrayList<Client>();
	private ClientDao dao = new ClientDaoImpl();
	private Client selectClient = new Client();
	private int totalClients;
	private Map<String, String> stateList = new LinkedHashMap<String, String>();

	public ClientBean() {
		insertStates();
		clients = dao.consultar();
		setTotalClients(clients.size());
	}

	public void save() {
		if(CheckCpf.checkCpf(client.getCpf())){
			if(Utils.checkMail(client.getMail())){
				dao.save(client);
				client = new Client();
			}else{
				geraMsg("E-mail inválido");
			}
		}else{
			geraMsg("Cpf inválido");
		}
		clients = dao.consultar();
		setTotalClients(clients.size());
	}

	public void edit() {
		if(CheckCpf.checkCpf(selectClient.getCpf())){
			if(Utils.checkMail(selectClient.getMail())){
				dao.save(selectClient);
				geraMsg("Cliente alterado com sucesso");
			}else{
				geraMsg("E-mail inválido");
			}
		}else{
			geraMsg("Cpf inválido");
		}
		clients = dao.consultar();
		setTotalClients(clients.size());
	}

	public void delete() {
		dao.delete(client);
		clients = dao.consultar();
		setTotalClients(clients.size());
		geraMsg("Cliente excluido com sucesso");
	}

	public void insertStates(){
		stateList.put("SP","SP");
		stateList.put("AC","AC");
		stateList.put("AL","AL");
		stateList.put("AP","AP");
		stateList.put("AM","AM");
		stateList.put("BA","BA");
		stateList.put("CE","CE");
		stateList.put("DF","DF");
		stateList.put("ES","ES");
		stateList.put("GO","GO");
		stateList.put("MA","MA");
		stateList.put("MT","MT");
		stateList.put("MS","MS");
		stateList.put("MG","MG");
		stateList.put("PA","PA");
		stateList.put("PB","PB");
		stateList.put("PR","PR");
		stateList.put("PE","PE");
		stateList.put("PI","PI");
		stateList.put("RJ","RJ");
		stateList.put("RN","RN");
		stateList.put("RS","RS");
		stateList.put("RO","RO");
		stateList.put("RR","RR");
		stateList.put("SC","SC");
		stateList.put("SE","SE");
		stateList.put("TO","TO");
	}
	
    public void onRowSelect(SelectEvent event) {  
        FacesMessage msg = new FacesMessage("Client Selected", ((Client) event.getObject()).getMail());  
        FacesContext.getCurrentInstance().addMessage(null, msg);  
    }  
  
    public void onRowUnselect(UnselectEvent event) {  
        FacesMessage msg = new FacesMessage("Client Unselected", ((Client) event.getObject()).getMail());  
        FacesContext.getCurrentInstance().addMessage(null, msg);  
    }

	public Client getClient() {
		return client;
	}

	public void setClient(Client client) {
		this.client = client;
	}

	public List<Client> getClients() {
		return clients;
	}

	public void setClients(List<Client> clients) {
		this.clients = clients;
	}
    
	public int getTotalClients() {
		return totalClients;
	}

	public void setTotalClients(int totalClients) {
		this.totalClients = totalClients;
	}

	public Map<String, String> getStateList() {
		return stateList;
	}
	
	public Client getSelectClient() {
		return selectClient;
	}

	public void setSelectClient(Client selectClient) {
		this.selectClient = selectClient;
	}

	public void setStateList(Map<String, String> stateList) {
		this.stateList = stateList;
	}

	private void geraMsg(String mesagem) {
		logger.info(mesagem);
		FacesContext context = FacesContext.getCurrentInstance();
		context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Aviso:", mesagem));
	}
}

Espero que alguém possa me ajudar.

Obrigado

11 Respostas

L

Antes de tudo insere no xhtml: <f:view> no teu body.

&lt;h:body&gt; &lt;f:view&gt; &lt;/f:view&gt; &lt;/h:body&gt;

e adiciona acima do head <f:view contentType=“text/html” />

&lt;f:view contentType="text/html" /&gt; &lt;h:head&gt; &lt;/h:head&gt;

R

Até fiz as alterações, mas não ajudou muito.

Quando carrego a página, o bean é acionado para fazer a consulta. Mas qualquer ação de botão não aciona o bean.

L

De qual botão você está falando? O Botão dentro da tabela ou o botão do teu dialog? O teu dialog chega ha abrir?

A

Cara não acredito que seja isso, mas não é boa pratica colocar só um form para tudo, coloque um para a tabela e um para cada ação:edição, inclusão e exclusão

R

O botão de dentro da tabela abre a dialog, mas não atualiza os campos da dialog, mostrando todos os campos em branco. Caso eu clique no botão de inserir, coloque os dados na dialog e clico em salvar, nada acontece, apenas a dialog fecha, mas a ação actionListener="#{clientBean.save}" não é chamada.

R

AmauriSpPoa: Colocaria cada dialog dentro de um form distinto?

A

Segue um exemplo.

&lt;?xml version='1.0' encoding='UTF-8' ?&gt; &lt;!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;ui:composition xmlns:ui="http://java.sun.com/jsf/facelets" template="../../template/report.xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"&gt; &lt;ui:define name="content"&gt; &lt;h:form id="formtbl"&gt; &lt;p:dataTable id="tbl" value="#{acaoController.items}" var="item" rows="10" rowStyleClass="#{empty rowIx or rowIx mod 2 ne 0 ? 'even-row' : 'odd-row'}" rowIndexVar="rowIx" paginator="true" lazy="true"&gt; &lt;p:column headerText="#{bundle.ListAcaoTitle_id}" sortBy="#{item.id}" filterBy="#{item.id}"&gt; &lt;h:outputText value="#{item.id}"/&gt; &lt;/p:column&gt; &lt;p:column headerText="#{bundle.ListAcaoTitle_descricao}" sortBy="#{item.descricao}" filterBy="#{item.descricao}"&gt; &lt;h:outputText value="#{item.descricao}"/&gt; &lt;/p:column&gt; &lt;p:column style="width: 115px;" headerText="Acoes"&gt; &lt;p:commandButton oncomplete="confirmation.show()" icon="ui-icon ui-icon-trash" title="Excluir" rendered="#{acaoController.acessos['Excluir']}"&gt; &lt;f:setPropertyActionListener value="#{item}" target="#{acaoController.selected}" /&gt; &lt;/p:commandButton&gt; &lt;p:commandButton update=":formview:view" icon="ui-icon ui-icon-search" title="Visualizar" oncomplete="view.show()" rendered="#{acaoController.acessos['Visualizar']}"&gt; &lt;f:setPropertyActionListener value="#{item}" target="#{acaoController.selected}" /&gt; &lt;/p:commandButton&gt; &lt;p:commandButton update=":formedit:edit" icon="ui-icon ui-icon-pencil" title="Editar" oncomplete="edit.show()" rendered="#{acaoController.acessos['Editar']}"&gt; &lt;f:setPropertyActionListener value="#{item}" target="#{acaoController.selected}" /&gt; &lt;/p:commandButton&gt; &lt;/p:column&gt; &lt;/p:dataTable&gt; &lt;/h:form&gt; &lt;h:form&gt; &lt;p:commandButton actionListener="#{acaoController.newObject}" oncomplete="insert.show()" value="novo" update=":forminsert:insert" rendered="#{acaoController.acessos['Adicionar']}"/&gt; &lt;/h:form&gt; &lt;/ui:define&gt; &lt;ui:define name="out"&gt; &lt;p:dialog widgetVar="view" modal="true"&gt; &lt;h:form id="formview"&gt; &lt;p:growl id="glow"/&gt; &lt;ui:include src="View.xhtml"&gt;&lt;/ui:include&gt; &lt;p:commandButton value="Cancelar" onclick="view.hide()"/&gt; &lt;/h:form&gt; &lt;/p:dialog&gt; &lt;p:dialog widgetVar="edit" modal="true"&gt; &lt;h:form id="formedit"&gt; &lt;p:growl id="glow"/&gt; &lt;ui:include src="Edit.xhtml"&gt;&lt;/ui:include&gt; &lt;p:commandButton value="Salvar" actionListener="#{acaoController.update}" oncomplete="if(args.ok == true) { edit.hide(); }" update=":formtbl:tbl glow" rendered="#{acaoController.acessos['Editar']}"/&gt; &lt;p:commandButton value="Cancelar" onclick="edit.hide()"/&gt; &lt;/h:form&gt; &lt;/p:dialog&gt; &lt;p:dialog widgetVar="insert" modal="true"&gt; &lt;h:form id="forminsert"&gt; &lt;p:growl id="glow"/&gt; &lt;ui:include src="Create.xhtml"&gt;&lt;/ui:include&gt; &lt;p:commandButton value="Salvar" actionListener="#{acaoController.insert}" oncomplete="if(args.ok == true) { insert.hide(); }" update=":formtbl:tbl :forminsert:insert glow" rendered="#{acaoController.acessos['Adicionar']}"/&gt; &lt;p:commandButton value="Cancelar" onclick="insert.hide()"/&gt; &lt;/h:form&gt; &lt;/p:dialog&gt; &lt;p:confirmDialog message="Excuir?" widgetVar="confirmation"&gt; &lt;h:form&gt; &lt;p:growl id="glow"/&gt; &lt;p:commandButton value="Sim" actionListener="#{acaoController.delete}" oncomplete="confirmation.hide()" update=":formtbl:tbl glow" rendered="#{acaoController.acessos['Excluir']}"/&gt; &lt;p:commandButton value="Nao" onclick="confirmation.hide()"/&gt; &lt;/h:form&gt; &lt;/p:confirmDialog&gt; &lt;/ui:define&gt; &lt;/ui:composition&gt;

Onde tem ui:include eu estou adicionando um xhtml que possui os campos, mas você pode deixar do jeito que está o seu, na mesma pagina sem problemas.

L

Aqui nos meus sistemas eu utilizo um form separadamente para os dialogs conforme o AmauriSpPoa comentou.
Segue um exemplo:

&lt;ui:composition
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui"
    template="/templates/template.xhtml"&gt;
    &lt;ui:define name="content"&gt;
        &lt;h:form id="form_cadastro"&gt;
            &lt;ui:include src="/pages/fragmentos/statusbar_carregando.xhtml" /&gt;
            &lt;ui:include src="/pages/cadastro/fragmentos/produto/menu_top.xhtml" /&gt;
            &lt;ui:include src="/pages/cadastro/fragmentos/produto/hot_key.xhtml" /&gt;
            &lt;div class="titulo_tela"&gt;
                &lt;h:outputText
                    id="titulo"
                    value="#{produtoBundle['produto.tela.nome']}" /&gt;
            &lt;/div&gt;
            &lt;p:growl
                id="messages"
                showDetail="false"
                autoUpdate="true" /&gt;
            &lt;p:tabView
                id="tab_view"
                widgetVar="varTabView"
                activeIndex="0"&gt;
                &lt;p:tab
                    id="tab0"
                    title="#{produtoBundle['produto.tab0.nome']}"&gt;
                    &lt;ui:include src="/pages/cadastro/fragmentos/produto/formulario.xhtml" /&gt;
                &lt;/p:tab&gt;
                &lt;p:tab
                    id="tab3"
                    title="#{produtoBundle['produto.tab3.nome']}"&gt;
                    &lt;ui:include src="/pages/cadastro/fragmentos/produto/formulario_tab_dimensoes.xhtml" /&gt;
                &lt;/p:tab&gt;
                &lt;p:tab
                    id="tab1"
                    title="#{produtoBundle['produto.tab1.nome']}"&gt;
                    &lt;ui:include src="/pages/cadastro/fragmentos/produto/formulario_caracteristicas.xhtml" /&gt;
                &lt;/p:tab&gt;
                &lt;p:tab
                    id="tab2"
                    title="#{produtoBundle['produto.tab2.nome']}"&gt;
                    &lt;ui:include src="/pages/cadastro/fragmentos/produto/formulario_tab_fotos.xhtml" /&gt;
                &lt;/p:tab&gt;
                &lt;p:tab
                    id="tab4"
                    title="#{produtoBundle['produto.tab4.nome']}"&gt;
                    &lt;ui:include src="/pages/cadastro/fragmentos/produto/tabela.xhtml" /&gt;
                &lt;/p:tab&gt;
            &lt;/p:tabView&gt;
        &lt;/h:form&gt;
    &lt;/ui:define&gt;
    &lt;ui:define name="dialog"&gt;
        &lt;h:form id="form_dialog"&gt;
            &lt;ui:include src="/pages/cadastro/fragmentos/produto/dialog_excluir.xhtml" /&gt;
            &lt;ui:include src="/pages/cadastro/fragmentos/produto/dialog_excluir_caracteristica.xhtml" /&gt;
        &lt;/h:form&gt;
    &lt;/ui:define&gt;
&lt;/ui:composition&gt;
O meu datatable fica assim:
&lt;ui:fragment
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui"&gt;

    &lt;p:dataTable
        id="tabela"
        var="bean"
        lazy="true"
        value="#{produtoMB.lazyDataModel}"
        paginator="true"
        paginatorPosition="top"
        rows="8"
        paginatorTemplate="#{globalBundle['sistema.datatable.paginatorTemplate']}"
        currentPageReportTemplate="#{globalBundle['sistema.datatable.currentPageReportTemplate']}"
        emptyMessage="#{globalBundle['sistema.datatable.emptymessage']}"&gt;
        &lt;p:column
            id="bean_codigo"
            sortBy="#{bean.id}"
            headerText="#{produtoBundle['produto.datatable.headertext.codigo']}"
            style="width:70px; text-align:center"&gt;
            &lt;h:outputText value="#{bean.id}" /&gt;
        &lt;/p:column&gt;
        &lt;p:column
            id="bean_sku"
            sortBy="#{bean.sku}"
            headerText="#{produtoBundle['produto.datatable.headertext.sku']}"&gt;
            &lt;h:outputText value="#{bean.sku}" /&gt;
        &lt;/p:column&gt;
        &lt;p:column
            id="bean_nome"
            sortBy="#{bean.nome}"
            headerText="#{produtoBundle['produto.datatable.headertext.nome']}"&gt;
            &lt;h:outputText value="#{bean.nome}" /&gt;
        &lt;/p:column&gt;
        &lt;p:column
            id="bean_acao"
            headerText="#{globalBundle['sistema.datatable.headertext.acao']}"
            style="width:30px"&gt;
            &lt;h:panelGrid
                columns="2"
                styleClass="menu_acao_tabela"&gt;
                &lt;p:commandButton
                    id="btn_editar_tabela"
                    title="#{globalBundle['sistema.datatable.btn.acao.alterar']}"
                    icon="#{iconeBundle['menu.topo.alterar.css']}"
                    update=":form_cadastro"
                    onclick="varTabView.select(0);"&gt;
                    &lt;f:param
                        name="disableBeanValidation"
                        value="true" /&gt;
                    &lt;f:setPropertyActionListener
                        value="#{bean}"
                        target="#{produtoMB.beanSelecionadoEditar}" /&gt;
                &lt;/p:commandButton&gt;
                &lt;p:commandButton
                    id="btn_excluir_tabela"
                    title="#{globalBundle['sistema.datatable.btn.acao.excluir']}"
                    icon="#{iconeBundle['menu.topo.excluir.css']}"
                    oncomplete="confirmExcluirDialog.show()"
                    update=":form_dialog:dialog_confirma_excluir, :form_cadastro"&gt;
                    &lt;f:param
                        name="disableBeanValidation"
                        value="true" /&gt;
                    &lt;f:setPropertyActionListener
                        value="#{bean}"
                        target="#{produtoMB.beanSelecionadoExcluir}" /&gt;
                    &lt;f:setPropertyActionListener
                        value="true"
                        target="#{produtoMB.excluirDaTabela}" /&gt;
                &lt;/p:commandButton&gt;
            &lt;/h:panelGrid&gt;
        &lt;/p:column&gt;
    &lt;/p:dataTable&gt;
&lt;/ui:fragment&gt;

O meu dialog fica assim:

&lt;ui:fragment
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui"&gt;
    &lt;p:dialog
        header="#{globalBundle['sistema.dialog.excluir.header']}"
        modal="true"
        widgetVar="confirmExcluirDialog"
        resizable="false"
        id="dialog_confirma_excluir"
        showEffect="fade"
        hideEffect="explode"
        closable="false"&gt;
        &lt;h:panelGrid columns="2"&gt;
            &lt;h:outputLabel
                for="codigo_dialog_excluir"
                value="#{produtoBundle['produto.dialog.label.codigo']}" /&gt;
            &lt;h:outputLabel
                id="codigo_dialog_excluir"
                value="#{produtoMB.bean.id}" /&gt;
            &lt;h:outputLabel
                for="nome_dialog_excluir"
                value="#{produtoBundle['produto.dialog.label.nome']}" /&gt;
            &lt;h:outputLabel
                id="nome_dialog_excluir"
                value="#{produtoMB.bean.nome}" /&gt;
        &lt;/h:panelGrid&gt;
        &lt;center&gt;
            &lt;h:panelGrid&gt;
                &lt;h:outputText value="#{globalBundle['sistema.dialog.excluir.pergunta']}" /&gt;
            &lt;/h:panelGrid&gt;
            &lt;h:panelGrid
                columns="2"
                cellpadding="3"&gt;
                &lt;p:commandButton
                    id="btn_confirma_sim"
                    value="#{globalBundle['sistema.dialog.excluir.btn.confirmar.sim']}"
                    oncomplete="confirmExcluirDialog.hide()"
                    update=":form_cadastro"
                    actionListener="#{produtoMB.excluir}" /&gt;
                &lt;p:commandButton
                    id="btn_confirma_nao"
                    value="#{globalBundle['sistema.dialog.excluir.btn.confirmar.nao']}"
                    onclick="confirmExcluirDialog.hide()"
                    update=":form_cadastro"
                    actionListener="#{produtoMB.cancelaExcluir}" /&gt;
            &lt;/h:panelGrid&gt;
        &lt;/center&gt;
    &lt;/p:dialog&gt;
&lt;/ui:fragment&gt;

abraço

D

Aparece algum erro?

Lembrando que seu conteúdo precisa estar no mesmo form

R

O maior dos problemas é esse, rs… Nenhum erro.

D

Tenta dar uma olhada no firebug no momento do click, as vezes mostra algum erro

Criado 2 de janeiro de 2013
Ultima resposta 3 de jan. de 2013
Respostas 11
Participantes 4