Fórum Edição e exclusão no dataTable usando Dialog Framework #533483
04/10/2015
0
Pessoal,
Preciso executar as ações de edição e exclusão em um dataTable usando o dialog framework. Como fazer isso? Alguém teria um exemplo?
Segue abaixo o código que fiz:
ClienteBean
Botão que chama o dialog
CadastroProfissao.xhtml
Por enquanto, só adicionei o botão "Excluir".
Obrigada pela ajuda.
Preciso executar as ações de edição e exclusão em um dataTable usando o dialog framework. Como fazer isso? Alguém teria um exemplo?
Segue abaixo o código que fiz:
ClienteBean
public void abrirDialogo() {
Map<String,Object> opcoes = new HashMap<String, Object>();
opcoes.put("modal", true);
opcoes.put("draggable", false);
opcoes.put("resizable", false);
opcoes.put("contentHeight", 600);
opcoes.put("contentWidth", 800);
RequestContext.getCurrentInstance().openDialog("CadastroProfissao", opcoes, null);
}
Botão que chama o dialog
<p:commandButton value="Profissões" action="#{clienteBean.abrirDialogo()}" icon="ui-icon-extlink" ajax="false" process="@this" update="@none">
<f:setPropertyActionListener target="#{clienteBean.profissao}" value="#"/>
</p:commandButton>
CadastroProfissao.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<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:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Incluir Profissão</title>
<style type="text/css">
.ui-widget {
font-size: 90%;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<h:outputStylesheet library="css" name="sistema.css" />
<h:outputScript library="jscript" name="locale-primefaces.js" />
</h:head>
<h:body>
<h:form id="form">
<p:growl id="growl" autoUpdate="true" sticky="true"/>
<p:toolbar style="margin-top: 10px">
<p:toolbarGroup>
<p:commandButton action="#{profissaoBean.salvar}" value="Salvar" ajax="false" update="@form" icon="ui-icon-disk"/>
</p:toolbarGroup>
</p:toolbar>
<p:fieldset style="margin-top: 20px">
<h:panelGrid columns="2" style="margin-top: 10px" cellpadding="5">
<h:outputLabel value="Descrição: " for="descricao" />
<p:inputText id="descricao" value="#{profissaoBean.profissao.descricao}" size="50" immediate="true"
onkeydown="this.value = this.value.toUpperCase();" onkeyup="this.value = this.value.toUpperCase()"/>
</h:panelGrid>
</p:fieldset>
<p:dataTable value="#{profissaoBean.profissoes}" var="profissao" id="profissoesTable" editable="true"
scrollable="true" scrollHeight="350" emptyMessage="Nenhuma profissão encontrada.">
<p:column headerText="Código" style="width: 10%">
<h:outputText value="#{profissao.codigo}" />
</p:column>
<p:column headerText="Descrição" style="width: 80%">
<h:outputText value="#{profissao.descricao}" />
</p:column>
<p:column headerText="Ações" style="width: 20%; text-align: center">
<p:commandButton title="Excluir" action="#{profissaoBean.excluir()}" icon="ui-icon-trash" update="@form">
<p:confirm header="Exclusão" message="Confirma a exclusão da profissao?" icon="ui-icon-alert"/>
<f:setPropertyActionListener target="#{profissaoBean.profissao}" value="#" />
</p:commandButton>
<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
<p:commandButton value="Sim" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
<p:commandButton value="Não" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
</p:confirmDialog>
</p:column>
</p:dataTable>
</h:form>
</h:body>
</html>
Por enquanto, só adicionei o botão "Excluir".
Obrigada pela ajuda.
Sgrandini
Curtir tópico
+ 0
Responder
Clique aqui para fazer login e interagir na Comunidade :)