Question how to submit a JSF form using <p:confirmDialog>

Asked

Viewed 437 times

1

I wanted to know how I send a form using the 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, when confirming the form to be sent.

I tried to change the type to 'button', I left no type and nothing.

Thank you to all who help

  • 2

    Post your code to better help you.

  • I voted to reopen, because I believe I can provide an example, even without much knowledge of Primefaces. I believe it was hasty to close, but everything that is closed can be reopened :)

  • 1

    @Guilhermenascimento I gave my vote to reopen this question. It could help to reopen this other?

  • Good evening, the answer solved your problem?

2 answers

1

According to the documentation http://www.primefaces.org/showcase/ui/overlay/confirmDialog.xhtml the use would be something like:

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 the 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 method meuEvento I believe to be the one that will save the data.

0

puts it like this

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.