Doubt of how to submit a form in JSF using p: confirmDialog

1

I would like to know how I can send a Form using p:comfirmdialog .

The idea is to get the message tem certeza ? , with the options sim or não . If you click sim , then it sends the form.

 <p:commandButton value="destruir o mundo" >
    <p:confirm header="confirmação" message="tem certeza ?" icon="ui-icon-alert" />
</p:commandButton>

<p:confirmDialog global="true" Effect="fade" hideEffect="fade">
    <p:commandButton value="sim" type="submit"  icon="ui-icon-check" />
    <p:commandButton value="No" type="button"  icon="ui-icon-close" />
</p:confirmDialog>

These commands are already inside the form, so I wanted it, when I confirmed the form was sent.

I have already tried to change the type to 'button', I already left without type and nothing.

Thanks to all who help

    
asked by anonymous 21.10.2015 / 13:22

2 answers

1

According to the link documentation the usage would look something like:

The xhtml would look like this:

<h:form>           
    <p:growl id="message" showDetail="true" />

    <p:commandButton value="Chamar o evento" actionListener="#{dialogView.meuEvento}" update="message">
        <p:confirm header="Confirmação" message="Você está certo disto?" icon="ui-icon-alert" />
    </p:commandButton>

    <p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
        <p:commandButton value="Yes" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
        <p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
    </p:confirmDialog>
</h:form>

And java:

package org.primefaces.showcase.view.overlay;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;

import org.primefaces.event.CloseEvent;

@ManagedBean
public class DialogView
{ 
    public void meuEvento()
    {
        addMessage("System Error", "Por favor tente novamente");
    }

    public void addMessage(String summary, String detail)
    {
        FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, summary, detail);
        FacesContext.getCurrentInstance().addMessage(null, message);
    }
}

The meuEvento method I believe to be what will save the data.

    
26.10.2015 / 00:45
0

So put

<p:commandLink action="">
    <p:confirm header="" message="" />
</p:commandLink>
    
23.09.2016 / 15:58