0

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.

Community
  • 1
  • 1
amphibient
  • 29,770
  • 54
  • 146
  • 240
  • 1
    And here's a link to the [RequestContext showcase](http://primefaces.org/showcase/ui/misc/requestContext.xhtml). – DavidS Jul 01 '15 at 00:13
  • I would like to reopen this because I tried to implement the solution proposed in the other question 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. so I kindly request to reopen this question. thanks – amphibient Jul 02 '15 at 22:01
  • I'm not too sure anyone will see that besides me, and I don't have permission to do that sort of thing. You can always open a new question though, and even copy-paste from this one. – DavidS Jul 02 '15 at 22:23
  • done: http://stackoverflow.com/questions/31195729/synchronous-dialog-invocation-from-managed-bean – amphibient Jul 02 '15 at 22:34

0 Answers0