Problem with a commandButton inside a ConfirmDialog

UI Components for JSF
Post Reply
rodrigovz
Posts: 21
Joined: 12 Jul 2010, 18:19

30 Jul 2010, 23:45

The CommmandButton (which is inside of a ConfirmDialog) doesn't call the action method that I've defined

Code: Select all

    <p:commandLink onclick="confirmation.show()" title="#{i18n.eliminar}" />

           <p:confirmDialog message="Esta seguro que desea eliminar el registro"
                 showEffect="clip" hideEffect="clip"
                 header="Eliminar" severity="alert" widgetVar="confirmation">
                    <h:form>
                        <p:commandButton value="Aceptar"  action="#{controller.eliminar}"  onclick="confirmation.hide();"/>
                        <p:commandButton value="Cancelar" onclick="confirmation.hide()" />
                    </h:form>
         </p:confirmDialog>
The action "#{controller.eliminar}" isn't called. But if the commandButton is outside of the ConfirmDialog it works

Thanks.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

30 Jul 2010, 23:50

Maybe you are getting a validation error?

rodrigovz
Posts: 21
Joined: 12 Jul 2010, 18:19

30 Jul 2010, 23:56

In the glassfish console I don't see any error

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

30 Jul 2010, 23:57

No, I meant page validations, can you do;

Code: Select all

<p:commandLink onclick="confirmation.show()" title="#{i18n.eliminar}" />

           <p:confirmDialog message="Esta seguro que desea eliminar el registro"
                 showEffect="clip" hideEffect="clip"
                 header="Eliminar" severity="alert" widgetVar="confirmation">
                    <h:form>
                        <p:commandButton value="Aceptar"  action="#{controller.eliminar}"  onclick="confirmation.hide();" update="messages"/>
                        <p:commandButton value="Cancelar" onclick="confirmation.hide()" />
                    </h:form>
         </p:confirmDialog>

        <p:messages id="messages" />
So that it will display if there is any error.

rodrigovz
Posts: 21
Joined: 12 Jul 2010, 18:19

31 Jul 2010, 00:03

I tried this and it didn't show me any messages.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

31 Jul 2010, 00:12

Is an ajax event fired? Can you check with firebug?

Serial
Posts: 19
Joined: 17 Jun 2010, 03:06
Location: Brazil

01 Sep 2010, 01:10

I'm also having this problem, with the property ajax="true" the dialog closes but the action method is never called, with ajax="false" nothing happens at all.

I've tried to test it in firebug but i never used it and i wasn't able to find if the ajax event fired =|

my code

Code: Select all

<?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://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="Template.xhtml">
        <h:form prependId="false">
            <div align="center">
                Buscar Projeto
                <br/>
                <br/>

                <h:panelGrid columns="3">
                    <h:outputLabel value="Buscar: "/>
                    <h:selectOneMenu id="projeto" value="#{projetoBean.projeto_selecionado}" required="true" requiredMessage="Selecione um Projeto!">
                        <f:selectItems value="#{projetoBean.lista_projetos}"/>
                    </h:selectOneMenu>
                    <p:commandButton ajax="false" value="Buscar" action="#{projetoBean.buscar_Projeto}" update="growl"/>
                </h:panelGrid>

            </div>
        </h:form>
        <h:form prependId="false">

            <div >
                <h:panelGrid id="grid" columns="3">
                    <h:outputText value="Nome do Projeto: " />                    
                    <h:inputText id="nome" required="true" requiredMessage="Digite o nome do Projeto!" maxlength="45"  value="#{projetoBean.nome}"/>
                    <h:outputText style="color: red" value="*"/>
                    <h:outputText value="Descrição: "/>                    
                    <h:inputText id="descricao" maxlength="200"  value="#{projetoBean.descricao}"/>
                    <h:outputText  value=""/>
                    <h:outputText value="Data de Início: "/>                    
                    <p:calendar id="data_de_inicio" readOnlyInputText="true" pattern="dd/MM/yyyy" required="true" requiredMessage="Selecione a data de início!" effect="explode" locale="pt_BR" showButtonPanel="true" value="#{projetoBean.data_de_inicio}"/>
                    <h:outputText style="color: red" value="*"/>
                    <h:outputText value="Data de Término: "/>                   
                    <p:calendar id="data_de_termino" readOnlyInputText="true" pattern="dd/MM/yyyy" locale="pt_BR" effect="explode" showButtonPanel="true" value="#{projetoBean.data_de_termino}"/>
                    <h:outputText  value=""/>
                </h:panelGrid>

                <br/>
                <p:commandButton value="Salvar" onclick="confirmacao.show()"/>


                <p:confirmDialog message="Tem certeza que deseja modificar esse projeto?" header="Salvar" severity="warn"  widgetVar="confirmacao" position="center">

                    <p:commandButton ajax="true" value="Sim" update="growl" action="#{projetoBean.editarProjeto}" oncomplete="confirmacao.hide()" type="submit" />
                    <p:commandButton value="Não" onclick="confirmacao.hide()" type="button" />

                </p:confirmDialog>


                <br/>
            </div>
        </h:form>
        <p:growl id="growl" showDetail="true" />
    </ui:composition>

</html>
Using Primefaces 2.2.M1, JSF 2.0 on Netbeans 6.9 + glassfish v3

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

01 Sep 2010, 02:18

Hi Serial,

Please read forum guideline, especially number #6.

http://primefaces.prime.com.tr/forum/vi ... f=3&t=1194

Thanks.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 61 guests