1

I am using PrimeFaces 10 and I have a page with two different forms. One form is in a dialog:

 <p:dialog  widgetVar="myDlg" id="myDlg" modal="true" width="600">
    <h:form enctype="multipart/form-data" id="myDlgForm">
        <p:inputText id="myInput" value="#{myInput}" required="true">
    </h:form>
</p:dialog>

and there is a form on the page that has fileUpload

<h:form id="fileUploadForm" enctype="multipart/form-data">
    <p:messages id="messages" showDetail="false" closable="true">
        <p:autoUpdate/>
    </p:messages>
    <p:fileUpload listener="#{myFileUPloadView.handleFileUpload}" process="@this" mode="advanced" multiple="true" sizeLimit="1000000" fileLimit="6" widgetVar="fileUpload"/>
</h:form>

When I upload a file in fileUploadForm, I get the required message from the myInput input on myDlgForm. How can I prevent processing the dialog's form when I upload a file?

Sam Donato
  • 471
  • 6
  • 12
  • 2
    That should not be possible. O nly 1 form is submitted at a time so it sounds like to me your `myDlg` is actually wrapped inside an outer form and that is what is being submitted. HTML spec only allows 1 form submit. – Melloware Jun 27 '22 at 14:42
  • See also https://stackoverflow.com/questions/7371903/how-to-use-hform-in-jsf-page-single-form-multiple-forms-nested-forms – Jasper de Vries Jun 28 '22 at 07:12
  • I viewed the source on the rendered page and meticulously matched start and end form tags and the forms are not nested. – Sam Donato Jun 28 '22 at 15:35

1 Answers1

1

The issue was that I had two <p:remoteCommand's with the same name. Even though they were in different forms, they were both getting called which was triggering form validation on both forms.

Sam Donato
  • 471
  • 6
  • 12