0

I have the following code inside a registration form. Basically the button calls an action (an Ejb method and an Action listener which is an utility method). When the user submits the registration form, a primefaces dialog should appear telling the user that registration is being processed. The same dialog disappears once the form is submitted. This can be achieved by Primefaces UIBlock; however, it requires the commandButton to be ajax enabled.

I thought about using : onstart = display some modal dialog & onsuccess or on complete = hide this dialog (<p:dialog widgetVar="dialog" ...) but this solution requires ajax to be enabled for primefaces commandButton.

Any clues on how I could achieve this while setting ajax to false inside a PrimeFaces commandButton?

Thanks

<h:form id="form_register">
            <p:panel id="panel_register">
<div align="center" style="padding: 5px;">
                    <p:commandButton id="register" ajax="true"
                        actionListener="#{mailBean.deliverEmail(newMember.email,newMember.name, newMember.username, newMember.password, newMember.isadmin)}"
                        action="#{memberController.register}" value="Register"
                        label="Register">
                        <f:setPropertyActionListener target="#{requestScope.wait}"
                            value="#{true}" />
                    </p:commandButton>
                </div>

<p:blockUI block="panel_register" trigger="register">
                    <h:outputText value="Please wait..." />
                    <br />
                    <p:graphicImage value="#{resource['gfx/gif.gif']}" />
                </p:blockUI>

EDIT: Thanks guys. I was mis-using the update the attribute in commandButton. Now things work fine.

Hanynowsky
  • 2,970
  • 5
  • 32
  • 43
  • Default value of `ajax` attribute is true. And where did you read that action is not called when `ajax` is true? This is just not true. – partlov Feb 04 '13 at 19:21
  • "As you know Primefaces commandButton does not trigger the action if its ajax attribute is set to true" **THIS IS PLAIN WRONG** – Kerem Baydoğan Feb 04 '13 at 19:21
  • If your action is not called you have some other problems in code so try to resolve them. Post `register` method from backing bean. And why would you use `bloskUI` to open dialog, you can do that with just button AJAX events. – partlov Feb 04 '13 at 19:23
  • There is no problem in the code as if I set ajax to false, the form gets submitted and everything works fine except that the – Hanynowsky Feb 04 '13 at 20:52
  • @KeremBaydoğan What I mean is that when ajax is set to true (default) the commandButton will do an ajax submit instead of an ordinary form submit (full page refresh). – Hanynowsky Feb 04 '13 at 21:03

1 Answers1

0

You should use the onstart and oncomplete actions to display/hide the dialog.

<p:commandButton id="register" onstart="dlg.show()" oncomplete="dlg.hide()" />