0
votes

I have a command button with an action that returns a new URL to redirect to. When this command button is not inside the p:dialog all works as I would expect, but when I put the command button in the dialog then the dialog just closes and leaves me on the same page.

<h:form id="reviewForm">
    <h:messages id="saveMsg" showDetail="true" globalOnly="true"/>
    <p:panel style="text-align: center">
        <p:commandButton type="button" value="Submit" onclick="showOptions(); areYouSureVar.show();" />
    </p:panel>
    <p:dialog id="areYouSure" widgetVar="areYouSureVar" resizable="false" width="400" modal="true" header="Are you sure you want to continue?">                                           
        <p:panel style="text-align: center">        
            <p:commandButton id="submit" ajax="false" value="Submit" action="#{mybean.myaction}" oncomplete="areYouSureVar.hide();"/>
            <p:commandButton type="button" value="Cancel" onclick="areYouSureVar.hide();"/>
        </p:panel>                            
    </p:dialog>
</h:form>

mybean.action returns a string that points to another page, but that page never loads, the dialog goes away and that is all.

2

2 Answers

1
votes

Untested but maybe this helps:

Checkout the primefaces documentation here (Version 3.3):http://primefaces.googlecode.com/files/primefaces_users_guide_3_3.pdf

At page 150 it says:

Use appendToBody with care as the page definition and html dom would be different, for example if dialog is inside an h:form component and appendToBody is enabled, on the browser dialog would be outside of form and may cause unexpected results. In this case, nest a form inside a dialog.

Nesting the dialog into a form element looks a bit strange to me.

0
votes

Hey can you try removing modal="true"? I tried it and it worked in my case.

Oh ya and I also had to remove showOptions() because I didn't I have it defined.