<P:Dialog> com <p:commandButton> não funciona e nem com <p:confirmDialog>

1 resposta
ChristinaMed
Estou com problemas em confirmar o ele esta sendo chamado normalmente, mas o botão de confirmação para adicionar a turma no evento que quero cadastrar não esta chamando o método
eventoMB.adicionar();

Já testei o método chamando com um botão fora do e funcionou perfeitamente, o problema então está no botão dentro do DIALOG.

Já troquei o
<p:dialog> pelo <p:confirmDialog>
e tmb o botão não chama o método
eventoMB.adicionar();

Alguém consegue visualizar algum erro?

<?xml version='1.0' encoding='UTF-8' ?>
<!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:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>CADASTRO DE EVENTO</title>
        <link rel="stylesheet" type="text/css" href="cadastro.css" />
        <style type="text/css">
            body {background-color: #c3d7c0; font-size: 12px}
        </style> 
    </h:head>
    <h:body>
        <div align="center">
            <p:layout style="min-width:1020px;max-width:1020px;min-height:600px">  
                <p:layoutUnit position="north" size="100">  
                    <h:graphicImage url="/imagem/saddo.png" />
                </p:layoutUnit>  

                <p:layoutUnit position="west" size="220">  
                    <ui:insert name="menu">
                        <h:form>
                            <p:panelMenu style="width:200px">

                              ...

                </p:layoutUnit>  
                <p:layoutUnit position="center">  
                    <ui:insert name="centro">

                        <h:form id="tabelaTurmas">
                            <p:dataTable value="#{turmaMB.listaTurmas}" var="t" emptyMessage="Não há cadastro" paginator="true" rows="6" >
                               
                               ...

                                 <p:column>
                                    <p:commandButton id="botaoSelecao" update=":formDialog:display" 
                                                     oncomplete="PF('turmaDialog').show()" 
                                                     icon="ui-icon-search" title="View">
                                        <f:setPropertyActionListener value="#{t}" target="#{eventoMB.turma}" />
                                    </p:commandButton>
                                </p:column>

                            </p:dataTable> 
                            <br/>
                        </h:form>
                        <h:form id="formularioEvento">
                            <p:panel id="formCadastroEven" header="Cadastrar novo Evento de Sugestões" >
                                <br/>
                                <p:messages for="formCadastroEven" closable="true"/>
                                <h:panelGrid columns="10" cellpadding="4"  >

                                    <h:form id="turmasEvento">
                                        <p:dataTable value="#{eventoMB.turmas}" var="v" emptyMessage="Turmas Adicionadas">
                                            <p:column>
                                                <f:facet name="header">
                                                    <h:outputText value="Horário" />
                                                </f:facet>
                                                <h:outputText value="${v.horario}"/>
                                            </p:column>

                                            <p:column>
                                                <f:facet name="header">
                                                    <h:outputText value="" />
                                                </f:facet>
                                                <h:outputText value="${v.disciplina.nome}"/>
                                            </p:column>
                                        </p:dataTable> 

                                        <blockquote/>
                                    </h:form> 

                                    <h:inputHidden value="#{eventoMB.evento.id}"/>
                                    <h:outputLabel value="Data Inicial:"/>
                                    <p:calendar   id="data" value="#{eventoMB.evento.dataInicial}" required="true" requiredMessage="Campo Obrigatório">
                                    </p:calendar>
                                    <h:outputLabel value="Data Final:"/>
                                    <p:calendar   id="campoDataFin" value="#{eventoMB.evento.dataFinal}" required="true" requiredMessage="Campo Obrigatório">
                                    </p:calendar>
                                </h:panelGrid>
                                <p:commandButton ajax="false" value="Cadastrar" action="#{eventoMB.cadastro()}" image="ui-icon-disk" update=":formCadastroEven" />
                                <br/><br/>
                            </p:panel>
                 
                        </h:form>

                    </ui:insert>
                </p:layoutUnit>  
            </p:layout>  
        </div>

        <p:growl id="growl" showDetail="true" life="3000" />

        <p:dialog header="Detalhe" resizable="true" widgetVar="turmaDialog" id="turmaDlg" showEffect="fade" hideEffect="explode">
            <h:form id="formDialog">
                <h:panelGrid id="display" columns="2" cellpadding="4"
                             style="margin:0 auto;">
                    <h:outputText value="Turma:" />
                    <h:outputText value="#{eventoMB.turma.horario}"
                                  style="font-weight:bold" />
                   
                        <p:commandButton value="Sim" type="button" actionListener="#{eventoMB.adicionar()}" icon="ui-icon-check" update=":turmaEvento , :growl"  onclick="PF('turmaDialog').show()"  />
                        <p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
                    
                </h:panelGrid>

            </h:form>
        </p:dialog>

    </h:body>
</html>
public EventoMB(){


...

 public void adicionar() {

        item.setTurma(getTurma());
        eventoAtual(getTurma());
        evento.addTurma(item);
        itensEvento.add(item);
        item = new ItemEvento();

    }

}

1 Resposta

C

Eu tive que fazer com h:commandLink e p:ajax para funcionar, não sei se é a solução ideal.

<h:commandLink action="#{itemFace.doConfirmaBuscaUn}" onclick="dlgun.hide();"> 
                                <p:graphicImage value="#{pageContext.servletContext.contextPath}/resources/imagens/confirmar.png" width="15" height="15"/>
                                <f:setPropertyActionListener target="#{itemFace.selectedLinhaBuscaUn}" value="#{item}"/>    
                                <p:ajax update=":fmEditar:idTabView:idUn"/> 
                       </h:commandLink>
Criado 21 de novembro de 2014
Ultima resposta 7 de dez. de 2014
Respostas 1
Participantes 2