My form's submit button is calling a managed bean's submission processing method in a very standard behavioral pattern. However, as of the latest requirements update, some case scenarios (based on values chosen in the form) will need to prompt an overlay dialog requiring the user to enter notes, which are not required in other scenarios so we don't want to make it a steady part of the form.
To make it simple, imagine if the user selects "Foo" in one of the drop-downs in the regular form, no note is necessary but if (s)he selects "Bar", we want to prompt a note overlay dialog. The deciding logic whether this note is needed is in the managed bean.
I know how to prompt an overlay dialog from the JSF, as per the very helpful PrimeFaces
showcase example:
<p:commandButton value="Modal" type="button" onclick="PF('dlg2').show();" />
<p:dialog header="Modal Dialog" widgetVar="dlg2" modal="true" height="100">
<h:outputText value="This is a Modal Dialog." />
</p:dialog>
However, I am looking for a way to divert the flow of the managed bean's submit processing method that will render that note dialog, capture its data, and resume to call the EJB with that data included. How do I do the equivalent of PF('dlg2').show()
from the managed bean?
As was suggested in this answer, I tried using RequestContext
to pop the dialog open but the JS call to open the dialog was asynchronous, IOW, the dialog was opened without the thread waiting for the user input from a form in the dialog. I need it to be synchronous, meaning for the managed bean to pause the execution of that thread before the user submits the form data.