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?
You can use
RequestContextto run js code inside your managed beanMake sure its an ajax call – got no
ajax="false"like this
I assume you got some dialog defined…