Search code examples
primefacesdialogconfirmtabview

Primefaces p:confirmDialog inside tabView


I now have problem with using confirmDialog inside tabView. Here is my confirmDialog

<p:confirmDialog global="true" showEffect="fade" hideEffect="explode">
    <h:form>
        <p:commandButton value="Yes" type="button"
            styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
        <p:commandButton value="No" type="button"
            styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
    </h:form>
</p:confirmDialog>

In the 1st tabView, I have a button with confirmation

<p:commandButton value="Import" icon="ui-icon-arrowrefresh-1-w"
    update=":form:growl">
    <p:confirm header="Confirmation" message="Are you sure?" />
</p:commandButton>

In the 2nd tabView, I have exactly that button.

And now my problem is: In the 1st tab, my confirmDialog have full text as I want: header and message, however in the 2nd tab, the header and message all become "null". Only button yes and no of confirmDialog still work. I don't know what is happening, please help me, how to make confirmDialog display full content in all tabView


Solution

  • It seems to work ok for me. See example below

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:p="http://primefaces.org/ui">
    <h:head>
        <title>JSF User Dialog</title>
    </h:head>
    <h:body>
        <h3>This is a JSF view.</h3>
        <h:form id="form">
            <p:confirmDialog global="true" showEffect="fade" hideEffect="explode">
                <h:form>
                    <p:commandButton value="Yes" type="button"
                        styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
                    <p:commandButton value="No" type="button"
                        styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
                </h:form>
            </p:confirmDialog>
    
            <p:tabView id="tabView">
    
                <p:tab id="tab1" title="Tab one ">
                    <p:commandButton value="Import" icon="ui-icon-arrowrefresh-1-w"
                        update=":form">
                        <p:confirm header="Confirmation" message="Are you sure?" />
                    </p:commandButton>
                </p:tab>
    
                <p:tab id="tab2" title="Tab two">
                    <p:commandButton value="Import" icon="ui-icon-arrowrefresh-1-w"
                        update=":form">
                        <p:confirm header="Confirmation" message="Are you sure?" />
                    </p:commandButton>
                </p:tab>
    
    
            </p:tabView>
        </h:form>
    </h:body>
    </html>
    

    Output:

    Tab 1 with dialog box Tab 2 with dialog box

    It would be good if you post your full xhtml code so we can see what could be the problem there.