ConfirmDialog is not displayed

I am currently looking at a JavaEE7 tutorial, the current chapter is JSF / PrimeFaces. I need to add a confirmation dialog for a delete action, the page displays fine. When I click the commandButton (line 14) the actionListener is triggered, but confirm.show () throws an error in the web console: "Original error: Confirmation not defined" and confirmDialog will not be displayed. As I understand it, "widgetVar = confirm" is a definition. Would like to know what I am doing wrong.

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
  xmlns:f="http://xmlns.jcp.org/jsf/core"
  xmlns:h="http://xmlns.jcp.org/jsf/html"
  xmlns:p="http://primefaces.org/ui">   
<body>
    <f:view contracts="#{view.locale.language}">
        <ui:composition template="/template.xhtml">
            <ui:define name ="content">
                <h1>#{msg['listCampaigns.my_campaigns']}</h1>
                <h:form>
                    <p:dataTable value="#{campaignListProducer.campaigns}" var="campaign">
                        <p:column>
                            <p:commandButton onclick="confirmation.show()" actionListener="#{listCampaignsController.doDeleteCampaign(campaign)}" icon="ui-icon-close" />
                        </p:column>
                        <p:column>
                            <f:facet name="header">#{msg['listCampaigns.name']}</f:facet>
                            <h:outputText value="#{campaign.name}" />
                        </p:column>
                        <p:column>
                            <f:facet name="header">#{msg['listCampaigns.target_amount']}</f:facet>
                            <h:outputText value="#{campaign.targetAmount}">
                                <f:convertNumber type="currency" currencyCode="EUR" />
                            </h:outputText>
                        </p:column>
                        <p:column>
                            <f:facet name="header">#{msg['listCampaigns.donated_so_far']}</f:facet>
                            <h:outputText value="#{campaign.amountdonatedSoFar}">
                                <f:convertNumber type="currency" currencyCode="EUR" />
                            </h:outputText>
                        </p:column>
                        <p:column>
                            <p:commandLink value="#{msg['listCampaigns.edit']}" ajax="false" action="#{listCampaignsController.doEditCampaign(campaign)}">
                            </p:commandLink>
                        </p:column>
                        <p:column>
                            <p:commandLink value="#{msg['listCampaigns.list_donations']}" ajax="false" action="#{listCampaignsController.doListDonations(campaign)}">
                            </p:commandLink>
                        </p:column>
                        <p:column>
                            <p:commandLink value="#{msg['listCampaigns.form']}" ajax="false" action="#{listCampaignsController.doEditDonationForm(campaign)}">
                            </p:commandLink>
                        </p:column>                                                           
                    </p:dataTable>
                    <p:commandButton value="#{msg['listCampaigns.add_campaign']}" ajax="false" action="#{listCampaignsController.doAddCampaign()}" />                            
                    <p:confirmDialog message="#{msg['listCampaigns.ask_delete_campaign']}" 
                                     header="#{msg['listCampaigns.delete_campaign']}" 
                                     severity="alert" 
                                     widgetVar="confirmation" >
                        <p:commandButton value="#{msg['listCampaigns.yes']}" 
                                         oncomplete="confirmation.hide()" 
                                         ajax="false" 
                                         actionListener="#{listCampaignsController.commitDeleteCampaign}" />
                        <p:commandButton value="#{msg['listCampaigns.no']}" onclick="confirmation.hide()" type="button" />
                    </p:confirmDialog>                        
                </h:form>
        </ui:define>
    </ui:composition>
</f:view>

      

+3


source to share


1 answer


You need to access your dialog for PF('confirmation')

example eg.PF('confirmation').show()

This is a change made with the release of version 5



Widgets must be specified via "PF". e.g. PF ('widgetVarName'). Show () instead of widgetVarName.show ();

https://code.google.com/p/primefaces/wiki/MigrationGuide

+6


source







All Articles