The Primeface confirmation screen does not work

2

This is the screen that appears in my Browser

WhenIpressthedeletebuttonitsimplydoesnothing.Itdoesnotgenerateanyerrorsintheeclipseconsoles

Thisistheseparatecode

problemhere!

<p:columnstyle="width: 100px; text-align: center">
                    <p:button icon="ui-icon-pencil" title="Editar" />
                    <p:commandButton icon="ui-icon-trash" title="Excluir" oncomplete="confirmacaoExclusao.show()" />
                </p:column>
            </p:dataTable>

            <p:confirmDialog header="Exclusão de produto" message="Tem certeza que deseja excluir o produto?"
                widgetVar="confirmacaoExclusao">
                <p:button value="Não" onclick="confirmacaoExclusao.hide(); return false;" />
                <p:commandButton value="Sim" oncomplete="confirmacaoExclusao.hide();" />
            </p:confirmDialog>

Full Code

<ui:composition template="/WEB-INF/template/LayoutPadrao.xhtml"
    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"
    xmlns:pe="http://primefaces.org/ui/extensions">

    <ui:define name="titulo">Pesquisa Produtos</ui:define>
    <ui:define name="corpo">

        <h:form>
        <p:growl id="message" showDetail="true" />
            <h1>Pesquisa de Produtos</h1>

            <p:toolbar style="margin-top:20px">
                <p:toolbarGroup>
                    <p:commandButton value="Pesquisa" />
                </p:toolbarGroup>
                <p:toolbarGroup align="right">
                    <p:button value="Novo" outcome="/produtos/CadastroProduto" />
                </p:toolbarGroup>
            </p:toolbar>

            <p:panelGrid columns="2" id="painel"
                style="width:100%; margin-top:20px">

                <p:outputLabel value="SKU" for="sku" />
                <p:inputText id="sku" size="20" />

                <p:outputLabel value="Nome" for="nome" />
                <p:inputText id="nome" size="80" />

            </p:panelGrid>

            <p:dataTable id="produtosTable"
                value="#{pesquisaProdutosBean.produtosFiltrados}" var="produto"
                style="margin-top: 20px" emptyMessage="Nenhum produto encontrado."
                rows="20" paginator="true" paginatorAlwaysVisible="false"
                paginatorPosition="bottom">

                <p:column headerText="SKU" style="text-align: center; width: 100px">
                    <h:outputText value="123" />
                </p:column>

                <p:column headerText="Nome" >
                    <h:outputText value="Bola de morango" />
                </p:column>

                <p:column headerText="Categoria" style="width: 250px">
                    <h:outputText value="Doces - bolas de chikedkemd"  />
                </p:column>

                <p:column headerText="Valor Unitário" style="text-align: right; width: 120px">
                    <h:inputText value="123" styleClass="moeda"/>
                </p:column> 

                <p:column headerText="Estoque" style="text-align: center; width: 100px">
                    <h:outputText value="98" />

                </p:column> 

                <p:column style="width: 100px; text-align: center">
                    <p:button icon="ui-icon-pencil" title="Editar" />
                    <p:commandButton icon="ui-icon-trash" title="Excluir" oncomplete="confirmacaoExclusao.show()" />
                </p:column>
            </p:dataTable>

            <p:confirmDialog header="Exclusão de produto" message="Tem certeza que deseja excluir o produto?"
                widgetVar="confirmacaoExclusao">
                <p:button value="Não" onclick="confirmacaoExclusao.hide(); return false;" />
                <p:commandButton value="Sim" oncomplete="confirmacaoExclusao.hide();" />
            </p:confirmDialog>
        </h:form>
    </ui:define>
</ui:composition>

Why does not the confirmation screen appear?

this was the messages that generated on the consoles

mar 18, 2015 2:08:43 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
ADVERTÊNCIA: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:PeiddoVenda' did not find a matching property.
mar 18, 2015 2:08:43 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Server version:        Apache Tomcat/8.0.20
mar 18, 2015 2:08:43 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Server built:          Feb 15 2015 18:10:42 UTC
mar 18, 2015 2:08:43 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Server number:         8.0.20.0
mar 18, 2015 2:08:43 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: OS Name:               Windows 8.1
mar 18, 2015 2:08:43 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: OS Version:            6.3
mar 18, 2015 2:08:43 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Architecture:          amd64
mar 18, 2015 2:08:43 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Java Home:             C:\Program Files\Java\jre1.8.0_31
mar 18, 2015 2:08:43 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: JVM Version:           1.8.0_31-b13
mar 18, 2015 2:08:43 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: JVM Vendor:            Oracle Corporation
mar 18, 2015 2:08:43 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: CATALINA_BASE:         C:\workspace Web\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1
mar 18, 2015 2:08:43 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: CATALINA_HOME:         C:\workspace Web\apache-tomcat-8.0.20
mar 18, 2015 2:08:43 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dcatalina.base=C:\workspace Web\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1
mar 18, 2015 2:08:43 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dcatalina.home=C:\workspace Web\apache-tomcat-8.0.20
mar 18, 2015 2:08:43 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dwtp.deploy=C:\workspace Web\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps
mar 18, 2015 2:08:43 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Djava.endorsed.dirs=C:\workspace Web\apache-tomcat-8.0.20\endorsed
mar 18, 2015 2:08:43 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dfile.encoding=UTF-8
mar 18, 2015 2:08:43 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFORMAÇÕES: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre1.8.0_31\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jre1.8.0_31/bin/server;C:/Program Files/Java/jre1.8.0_31/bin;C:/Program Files/Java/jre1.8.0_31/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\Java\jdk1.8.0_25\bin;C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin;C:\Ruby21-x64\bin;C:\eclipse\eclipse luna\eclipse;;.
mar 18, 2015 2:08:43 PM org.apache.coyote.AbstractProtocol init
INFORMAÇÕES: Initializing ProtocolHandler ["http-nio-8080"]
mar 18, 2015 2:08:43 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFORMAÇÕES: Using a shared selector for servlet write/read
mar 18, 2015 2:08:43 PM org.apache.coyote.AbstractProtocol init
INFORMAÇÕES: Initializing ProtocolHandler ["ajp-nio-8009"]
mar 18, 2015 2:08:43 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFORMAÇÕES: Using a shared selector for servlet write/read
mar 18, 2015 2:08:43 PM org.apache.catalina.startup.Catalina load
INFORMAÇÕES: Initialization processed in 1152 ms
mar 18, 2015 2:08:43 PM org.apache.catalina.core.StandardService startInternal
INFORMAÇÕES: Starting service Catalina
mar 18, 2015 2:08:43 PM org.apache.catalina.core.StandardEngine startInternal
INFORMAÇÕES: Starting Servlet Engine: Apache Tomcat/8.0.20
mar 18, 2015 2:08:44 PM org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
INFORMAÇÕES: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [123] milliseconds.
mar 18, 2015 2:08:46 PM com.sun.faces.config.ConfigureListener contextInitialized
INFORMAÇÕES: Inicializando Mojarra 2.2.8-02 ( 20140915-1602 https://svn.java.net/svn/mojarra~svn/tags/2.2.8-02@13678) para o contexto '/PedidoVenda'
mar 18, 2015 2:08:47 PM com.sun.faces.spi.InjectionProviderFactory createInstance
INFORMAÇÕES: JSF1048: Anotações PostConstruct/PreDestroy presentes.  Os métodos ManagedBeans marcados com essas anotações informarão as anotações processadas.
mar 18, 2015 2:08:48 PM org.primefaces.webapp.PostConstructApplicationEventListener processEvent
INFORMAÇÕES: Running on PrimeFaces 5.1
mar 18, 2015 2:08:48 PM org.primefaces.extensions.application.PostConstructApplicationEventListener processEvent
INFORMAÇÕES: Running on PrimeFaces Extensions 3.0.0
mar 18, 2015 2:08:48 PM org.apache.coyote.AbstractProtocol start
INFORMAÇÕES: Starting ProtocolHandler ["http-nio-8080"]
mar 18, 2015 2:08:48 PM org.apache.coyote.AbstractProtocol start
INFORMAÇÕES: Starting ProtocolHandler ["ajp-nio-8009"]
mar 18, 2015 2:08:48 PM org.apache.catalina.startup.Catalina start
INFORMAÇÕES: Server startup in 5017 ms

    
asked by anonymous 18.03.2015 / 19:30

1 answer

2

You are trying to manually program the call to confirmDialog . That's not the idea. The idea is that confirmDialog overrides the default JavaScript commit, so you program the button normally to do what you have to do, and set it to invoke confirmation when the button is clicked.

So you do not have to program the confirmDialog call. Instead, you set the button so that the confirmation window is automatically invoked.

Your code should look something like this:

                    <p:commandButton icon="ui-icon-trash" title="Excluir" 
                        actionListener="#{bean.excluir()}">
                        <p:confirm header="Exclusão de produto" 
                            message="Tem certeza que deseja excluir o produto?" 
                            icon="ui-icon-alert" />
                    </p:commandButton>
                </p:column>
            </p:dataTable>

            <p:confirmDialog global="true">
                <p:commandButton value="Não" type="button" 
                    styleClass="ui-confirmdialog-yes" icon="ui-icon-check"/>
                <p:commandButton value="Sim" type="button" 
                    styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>
            </p:confirmDialog>

See the differences from your original code:

  • >
  • I have specified a p: confirm tag for the button. It is responsible for triggering confirmDialog .

  • header and message tags are specified in the p: confirm tag because the dialog is generic.

    li>
  • I added the global property to the confirmDialog . This component, in turn, has no explicitly programmed action. These are the ui-confirmdialog-yes and ui-confirmdialog-no classes on the buttons that identify which button the user clicked. Then, if the user clicks "Yes", the method associated with the Delete button (in this case, bean.exclude ) will be invoked .

18.03.2015 / 22:34