display a confirmation popup on button click based on condition

Posted by Raaz on Stack Overflow See other posts from Stack Overflow or by Raaz
Published on 2012-11-05T08:25:30Z Indexed on 2012/11/05 11:01 UTC
Read the original article Hit count: 266

Filed under:
|
|

I have a p:commandButton on click of which I need to add a few values to a list. In my managed bean, I'm validating the value that has to be added, and if it validates to false, I have to display a confirmation popup. This is my code -

<p:commandButton id="add" value="Add" type="submit"                                      action="#{bean.doAdd}" ajax="false"
update=":List"/>

And in the bean, on click of the "Add" button,

public String doAdd() throws Exception {
        if(response != null) {
            if(keyList.contains(response))  {
                if(!responseList.contains(response)) {
                    responseList.add(response);
                } 
            } else {
               //Have to display confirmation popup.
            }
            response = "";
        }

        return response;
    }

I'm using jsf 2.0 and primefaces 3.0. Can someone please tell me how to display the popup from the bean?

© Stack Overflow or respective owner

Related posts about java

Related posts about jsf