title: Prompting overlay for extra data by managed bean
body: <p>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.  </p>
  
  <p>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.</p>
  
  <p>I know how to prompt an overlay dialog from the JSF, as per the very helpful <code>PrimeFaces</code> <a href="http://www.primefaces.org/showcase/ui/overlay/dialog/basic.xhtml" rel="nofollow noreferrer">showcase example</a>:</p>
  
  <pre><code>&lt;p:commandButton value="Modal" type="button" onclick="PF('dlg2').show();" /&gt;
  
  &lt;p:dialog header="Modal Dialog" widgetVar="dlg2" modal="true" height="100"&gt;
      &lt;h:outputText value="This is a Modal Dialog." /&gt;
  &lt;/p:dialog&gt;
  </code></pre>
  
  <p>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 <code>PF('dlg2').show()</code> from the managed bean?</p>
  
  <p>As was suggested in <a href="https://stackoverflow.com/a/13474176/1312080">this answer</a>, I tried using <code>RequestContext</code> 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.</p>