title: <p:fileUpload> with other input elements (commandButton) in form
body: <p>I am trying to upload a file with a parameter which identifies the file, example if there is a parameter role, which contains student as value then uploading file should contain student details.</p>
  
  <p>So in a single form I am trying to capture roleid and using <code>&lt;p:fileUpload&gt;</code>, here when I select the role and click on file uploader selected role id is captured as null</p>
  
  <p>I am using JSF <code>p:fileUpload</code> following is the code:        </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;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:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"&gt;
  &lt;h:body&gt;
      &lt;ui:composition template="/templates/layout.xhtml"&gt;
          &lt;ui:define name="content"&gt;
  
              &lt;h:form enctype="multipart/form-data"&gt;
  
                  &lt;p:panel&gt;
  
                      &lt;h:panelGrid id="grid"&gt;
  
                          &lt;h:outputLabel for="role" value="Role" style="font-weight:bold" /&gt;
                          &lt;p:selectOneMenu id="role" value="#{userBean.selectedroleid}"
                              style="width:100%"&gt;
                              &lt;f:selectItem itemLabel="Select User Type" itemValue="" /&gt;
                              &lt;f:selectItems value="#{userBean.roles}" var="role"
                                  itemLabel="#{role.role}" itemValue="#{role.id}" /&gt;
                          &lt;/p:selectOneMenu&gt;
                          &lt;h:outputText value="" /&gt;
  
                      &lt;/h:panelGrid&gt;
  
                      &lt;f:facet name="footer"&gt;
                          &lt;p:fileUpload fileUploadListener="#{userBean.readCSVFile}"
                              mode="advanced" dragDropSupport="false" fileLimit="1"
                              allowTypes="/(\.|\/)(csv)$/" label="Select" immediate="true" /&gt;
                          &lt;p:commandButton value="Save" action="#{userBean.readCSVFile1()}"
                              style="margin:0px" update="grid" icon="ui-icon-disk"
                              validateClient="true" /&gt;
  
  
                      &lt;/f:facet&gt;
  
                  &lt;/p:panel&gt;
              &lt;/h:form&gt;
          &lt;/ui:define&gt;
      &lt;/ui:composition&gt;
  &lt;/h:body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>User bean: capture role and file       </p>
  
  <pre><code> @ManagedBean
      @ViewScoped
      public class UserBean implements Serializable {
  
  
          @Inject
          private RoleService roleService;
  
          private Integer selectedroleid;
  
          private List&lt;Role&gt; roles;
  
          public List&lt;Role&gt; getRoles() {
              return roles;
          }
          public void setRoles(List&lt;Role&gt; roles) {
              this.roles = roles; 
  
          }
          @PostConstruct
          public void initialize() {
  
              this.roles = roleService.getRoles();
  
          }   
  
          public void readCSVFile(FileUploadEvent event) throws IOException {
  
  
              logger.debug("Reading data from csv and convert to java object:");      
              System.out.println("selected role Id " + selectedroleid);
              System.out.println("selected file  " + event.getFile().getFileName());
  
          }
  
      public void readCSVFile1() throws IOException {
  
  
              logger.debug("Reading data from csv and convert to java object:");      
              System.out.println("selected role Id " + selectedroleid);   
  
          }
  
  
  
          public Integer getSelectedroleid() {
              return selectedroleid;
          }
  
          public void setSelectedroleid(Integer selectedroleid) {
              System.out.println(" selected role id "+ selectedroleid);
              this.selectedroleid = selectedroleid;
          }
  
  
  
      }
  </code></pre>
  
  <p>and I have Upload Filter mapping also in Web.xml, for uploading file using JSF.         </p>
  
  <pre><code>&lt;filter&gt;
          &lt;filter-name&gt;PrimeFaces FileUpload Filter&lt;/filter-name&gt;
          &lt;filter-class&gt;org.primefaces.webapp.filter.FileUploadFilter&lt;/filter-class&gt;
          &lt;init-param&gt;
          &lt;param-name&gt;thresholdSize&lt;/param-name&gt;
          &lt;param-value&gt;2097152&lt;/param-value&gt;
          &lt;/init-param&gt;     
          &lt;/filter&gt;
          &lt;filter-mapping&gt;
          &lt;filter-name&gt;PrimeFaces FileUpload Filter&lt;/filter-name&gt;
          &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
          &lt;/filter-mapping&gt; 
  </code></pre>
  
  <p>But the problem is that if I select the role and click on file uploader selected role id is captured as null, were as if I click Save button, correct value for role is getting capture at user bean.</p>
  
  <p>I want to get role id along with file upload or some how I want to capture both role and file in the same page.</p>