Primefaces <p:fileUpload/> bean setter not invoked when using a confirmation <p:dialog/> dialog

41 views Asked by At

I'm using Primefaces 8 and I could not seem to find solutions for my fileUpload setter not invoked when it includes a confirmation dialog.

The structure of my xhtml files is this

main.xhtml

<ui:define name="page-content">
    <ui:include src="/resources/fragment/tabs.xhtml"/>
</ui:define>
<ui:define name="dialogs">
    <ui:include src="/resources/fragment/dialog-confirmation.xhtml"/>
</ui:define>

tabs.xhtml

<p:tabView id="tabviews" activeIndex="#{tab.activeIndex}" dynamic="true">
    <ui:include src="/resources/fragment/tab1.xhtml"/>
    <ui:include src="/resources/fragment/tab2.xhtml"/>
    //so on
</p:tabView>

tab1.xhtml

<p:tab>
   <h:form id="tab1-form" enctype="multipart/form-data">

        <p:fileUpload mode="simple" value="#{bean.uploadedFile}"/>

        <p:commandLink
                value="Upload"
                onclick="void(0);"
                actionListener="#{bean.setDynamicParam('xxx')}"
                oncomplete="PF('confirmDialog').show();"/>
   </h:form>
</p:tab>

dialog-confirmation.xhtml

<h:form id="tab-dialog-form">
        <p:dialog
                id="tab-dialog"
                title="Confirm"
                widgetVar="confirmDialog" 
                modal="true" dynamic="true">
            <f:facet name="content">
                <h:outputFormat value="Confirm upload"/>
            </f:facet>
            <f:facet name="button">
                <p:commandButton
                        id="yes"
                        value="Yes"
                        oncomplete="PF('confirmDialog').hide();"
                        actionListener="#{bean.save()}"
                        update=":tabviews:tab1-form"
                        ajax="false">
                </p:commandButton>
                <p:commandButton
                        id="no"
                        type="button"
                        value="No"
                        onclick="PF('confirmDialog').hide();"/>
            </f:facet>
        </p:dialog>
</h:form>

bean is a ViewScoped bean, when bean.save() is invoked, fileUpload is checked for nullability but is always null. When I debugged, I confirmed that the fileUpload setter was not invoked, hence the null value.

Have followed BalusC's instructions here: How to use PrimeFaces p:fileUpload? Listener method is never invoked or UploadedFile is null / throws an error / not usable and works fine when there's no confirmation dialog and the "Upload" commandLink has ajax="false"

What am I missing here to have it working with p:dialog?

0

There are 0 answers