title: Multiple File Uploads - JSF
body: <p>I am using JSF 1.2 framework. Right now i am trying to implement a file upload process in which the number of files to be uploaded is controlled by the end user. Please find the below snapshot and code snippet for reference.</p>
  <p><img src="https://i.stack.imgur.com/PKcHM.png" alt="Multiple File Upload" /></p>
  <p><strong>XHTML Implementation:-</strong></p>
  <pre><code>&lt;a4j:commandLink action=&quot;#{importWSDLBean.xsdLoopIncrementAction}&quot; reRender=&quot;WSDLPanelGrid&quot;&gt;
   &lt;h:graphicImage value=&quot;/images/plus_icon.gif&quot; /&gt;
  &lt;/a4j:commandLink&gt;
  
  &lt;a4j:commandLink action=&quot;#{importWSDLBean.xsdLoopDecrementAction}&quot; reRender=&quot;WSDLPanelGrid&quot;&gt;
   &lt;h:graphicImage value=&quot;/images/minus_icon.gif&quot; /&gt;
  &lt;/a4j:commandLink&gt;
  
  &lt;h:panelGrid id=&quot;WSDLPanelGrid&quot;&gt;
   &lt;c:forEach items=&quot;#{importWSDLBean.acscDataList}&quot; var=&quot;inputFUpload&quot;&gt;
    &lt;t:inputFileUpload id=&quot;#{inputFUpload.id}&quot; value=&quot;#{inputFUpload.value}&quot; /&gt;
   &lt;/c:forEach&gt;
  &lt;/h:panelGrid&gt;
  </code></pre>
  <p><strong>Java Bean Implementation:-</strong></p>
  <pre><code>public String xsdLoopIncrementAction() {
      if (acscDataList == null) {
          acscDataList = new ACSCDataList(new ArrayList());
          HtmlInputFileUpload htmlUpload = new HtmlInputFileUpload();
          htmlUpload.setId(&quot;upload&quot; + (acscDataList.size() + 1));
          acscDataList.add(htmlUpload);
      } else {
          HtmlInputFileUpload htmlUpload = new HtmlInputFileUpload();
          htmlUpload.setId(&quot;upload&quot; + (acscDataList.size() + 1));
          acscDataList.add(htmlUpload);
      }
      return &quot;success&quot;;
  }
  
  
  public String xsdLoopDecrementAction() {
      if (acscDataList != null) {
          if (acscDataList.size() &gt; 0) {
              acscDataList.remove(acscDataList.size() - 1);
          }
      }
      return &quot;success&quot;;
  }
  </code></pre>
  <p>This implementation resets the file upload values whenever i increment or decrement the no. of file upload fields. Also when i submit the form i cant able to get the UploadedFile object (File Upload prerequisite such as Form type and Web.xml configuration is also included).</p>
  <p>Can anyone help me out?</p>