4 Replies Latest reply on Apr 29, 2011 6:03 AM by Pavel Mart

    JSF2+RichFaces 4.0: fileUpload

    Pavel Mart Newbie

      Hello, Dear Community,


      I need single file to be upload to a server from a page. I tried using fileUpload richfaces component but was failed to adjust it accordingly. Is it possible to make my own component to upload only one file when form is submitted or use some from external framework?


      I also tried to implement file uploading like it is suggested here http://ironicprogrammer.blogspot.com/2010/03/file-upload-in-jsf2.html, but even if I added "multipart/form-data" enctype for a form and use a4j:commandButton request content type is always "application/x-www-form-urlencoded" not "multipart/form-data". If I use h:commandButton the request type is "multipart/form-data", but action from back-end bean is never called

      Below is a part of JSF with two buttons


           <h:form enctype="multipart/form-data">

                  <h:panelGroup id="mainPanel">

                      <h:panelGrid columns="1">

                          <h:outputLabel for="name" value="#{msg['name']}"/>

                          <h:inputText value="#{documentController.name}" id="name"/>

                          <rich:message for="name" styleClass="err"/>



                      <input type="file" name="vcardFile"/>

                      <a4j:commandButton value="#{msg['save']}" action="#{documentController.uploadFile}" />

                      <h:commandButton action ="#{documentController.uploadFile}" value="Submit"/>




      Please, give me any tip how can I make it work or provide any solution for a single file upload.