manoj
manoj

Reputation: 71

How to popup a dialog box in jsf

I want to pop a window in JSF, when the user submit the value, a dialog box should popup with the id created and when user clicks ok button in dialog box the control should go to next tab.

I used prime faces button with oncomplete attribute to show pop up its working fine,but the problem is I do some validation in bean (like email address already exist).So by the time validation error shows the dialog box also popping up.

So can anyone guide me how to pop up the dialog only when id is created .

Upvotes: 2

Views: 4534

Answers (1)

Daniel
Daniel

Reputation: 37051

You can do something like this

<p:commandButton value="Show Only When No Validation Error"
    actionListener="#{myBean.myMethod}"
    oncomplete="if (args &amp;&amp; !args.validationFailed) myDialog.show()" />

Or inside your java code do something like this

public void myMethod() {
    //some code goes here
    if (!errorFound) {
        RequestContext.getCurrentInstance().execute("myDialog.show()");
    }
}

Upvotes: 1

Related Questions