You need to replace this line:
requestContext.openDialog("widget");
:
requestContext.execute("PF('widget').show()");
The RequestContext.openDialog () method refers to the Primefaces API, which is different from the p: dialog component.
From the interface guide:
A dialog box (DF) is used to open an external xhtml page in a dialog that is dynamically generated at run time.
, RequestContext.openDialog() , xhtml .
p: dialog javacript api show() hide() .