2 Replies Latest reply on Nov 23, 2008 10:07 PM by Grzegorz Bernas

    Can't upload files by rich:fileUpload

    Grzegorz Bernas Newbie
      I'm trying to upload files. But without any errors I cant't. I use Seam 2.0.2 SP1 and I add newest RF lib 3.2.2.SR1
      Do I need to ad something to my components.xml or web.xml?
      My bean:
      public class FileUpload {
           Log log;

           private ArrayList<PersonFile> files = new ArrayList<PersonFile>();

           public int getSize() {
                log.info("size: " + getFiles().size());
                if (getFiles().size() > 0) {
                     return getFiles().size();
                } else {
                     return 0;
           public void listener(UploadEvent event) throws IOException {
                UploadItem item = event.getUploadItem();
                PersonFile pfile = new PersonFile();
               System.out.println("File : '" + item.getFileName() + "' was uploaded");
               if (item.isTempFile()) {
                File file = item.getFile();
                System.out.println("Absolute Path : '" + file.getAbsolutePath() + "'!");
               }else {
                    try {
                          ByteArrayOutputStream b = new ByteArrayOutputStream();
                     } catch (Exception e) {
                          // TODO: handle exception

           public ArrayList<PersonFile> getFiles() {
                return files;

           public void setFiles(ArrayList<PersonFile> files) {
                this.files = files;

      My view:
                          <h:panelGrid columns="2" columnClasses="top,top">
                               <rich:fileUpload fileUploadListener="#{fileUpload.listener}" maxFilesQuantity="5" reRender="table" id="upload"
                                    immediateUpload="false" acceptedTypes="*" allowFlash="false" uploadData="#{fileUpload.files}">
                                    <a4j:support event="onuploadcomplete" reRender="info" />
                               <h:panelGroup id="info">
                                    <rich:panel bodyClass="info">
                                         <f:facet name="header">
                                              <h:outputText value="Uploaded Files Info" />
                                         <h:outputText value="No files currently uploaded" rendered="#{fileUpload.size==0}" />
                                         <rich:dataGrid columns="1" value="#{fileUpload.files}" var="file" rowKeyVar="row">
                                              <rich:panel bodyClass="rich-laguna-panel-no-header">
                                                   <h:panelGrid columns="2">
                                                        <h:panelGrid columns="2">
                                                             <h:outputText value="File Name:" />
                                                             <h:outputText value="#{file.filename}" />
                                    <rich:spacer height="3" />
                                    <br />
        • 2. Re: Can't upload files by rich:fileUpload
          Grzegorz Bernas Newbie
          I try all of this... and none of them works.
          I even try update my project from Seam 2.0.2 to 2.1.0.
          This is what I have:
          OS: Ubuntu 8.10 64 bit
          Server: jboss-4.2.3.GA
          Seam: jboss-seam-2.1.0.SP1
          IDE: Eclipse 3.4 \+ JBoss Tools 3.0 beta 1
          I try to use rich:fileUpload and s:fileUpload none of this works.
          I have 3 pojects: WAR, EAR and EJB. I have class that I try to put into ejb and war without result. I try byte\[\], InputStrem and UploadEvent as a method to handle file.
          My xhtml file:

          <h:form enctype="multipart/form-data">
                                          <s:fileUpload id="file" data="#{fileUpload.uploadedFileas}" accept="*" />
                                          <h:commandButton action="#{fileUpload.save}" value="upload">
                                          <f:param name="tab" value="personFiles" />

          my FileUpload.java in WAR project

          public class FileUpload
                  public void listener(UploadEvent event) throws IOException {
                          log.info("Execute listener");
                  public void data(byte[] data) {
                          log.info("get file...");
                  public void setUploadedFile(InputStream uploadedFile) {
                          this.uploadedFile = uploadedFile;
          in my components.xml I add:
          <web:multipart-filter create-temp-files="true" max-request-size="100000000" url-pattern="*.seam"/>
                  <component class="org.jboss.seam.web.MultipartFilter">
                          <property name="createTempFiles">true</property>
                          <property name="maxRequestSize">1000000</property>
          in my web.xml:

                  <filter-name>Seam Multipart Filter</filter-name>
                  <filter-name>Seam Multipart Filter</filter-name>

          And what I get? NONE! Whe I try to upload file I don\'t get any error! Even more, if I try to use in data=\"\" none existing method from none existing class I still don\'t have any exceptions... Why? I truly don\'t know what to do... PLEASE HELP MY :(