I want to dynamically create a primefaces dialog from the backing bean. I have written the code above:
public void s
You need to replace this line:
requestContext.openDialog("widget");
to that:
requestContext.execute("PF('widget').show()");
RequestContext.openDialog() method reffers to Primefaces Dialog Framework API which is different to p:dialog component.
From primefaces user guide:
Dialog Framework (DF) is used to open an external xhtml page in a dialog that is generated dynamically on runtime.
So, RequestContext.openDialog() expects you to provide path to xhtml page as argument.
And p:dialog component have javascript api show() and hide() methods to interact with it.