7 Replies Latest reply on Jun 3, 2009 5:08 AM by nbelaevski

    Problem with rich:fileUpload

      Hi Guys,

      I trying to use <rich:fileUpload> tag. When the page loads I get this javascript error.


      Error: $(this.id) is null
      Source File: http://kashif.localdomain:8080/RichFacesDemo/a4j/g/3_3_1.GAorg/richfaces/renderkit/html/js/progressBar.js.faces
      Line: 3


      I carry on to select a file by clicking add button. When a file is added and the Upload button becomes visible, I click the Upload button but I get this error.

      Error: this.progressBar is undefined
      Source File: http://kashif.localdomain:8080/RichFacesDemo/a4j/g/3_3_1.GAorg/richfaces/renderkit/html/js/FileUpload.js.faces
      Line: 18


      Below is my code.




      
      <%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
      <%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
      <%@taglib uri="http://richfaces.org/rich" prefix="rich"%>
      <%@taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
      
      <f:view>
       <h:form id="uploadForm" enctype="multipart/form-data">
      
       <rich:fileUpload fileUploadListener="#{fileUploadBean.listener}"
       id="uploadFiles">
       <f:facet name="progress">
       <rich:progressBar style="width:100px"></rich:progressBar>
       </f:facet>
       </rich:fileUpload>
      
      
       </h:form>
      </f:view>


      Please help me with this.

      Regards,
      Kashif

        • 1. Re: Problem with rich:fileUpload
          ilya_shaikovsky

          remove enctype="multipart/form-data" from the form. It is not required and should not be used with rf fileUpload.

          If you will get the same check please if the same works fine without custom progress bar.

          on my side your snippet works ok with 3.3.2 snapshot.

          • 2. Re: Problem with rich:fileUpload

            Thanks you very much

            • 3. Re: Problem with rich:fileUpload

              I have another problem with the same component.

              I copied the exact code from http://livedemo.exadel.com/richfaces-demo/richfaces/fileUpload.jsf and used as a demo application.

              But when I run that, I get this exception

              java.lang.NullPointerException
               at org.richfaces.renderkit.FileUploadRendererBase.doDecode(FileUploadRendererBase.java:140)
               at org.ajax4jsf.renderkit.RendererBase.decode(RendererBase.java:75)
               at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:761)
               at javax.faces.component.UIInput.decode(UIInput.java:719)
               at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1003)
               at javax.faces.component.UIInput.processDecodes(UIInput.java:633)
               at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:998)
               at javax.faces.component.UIForm.processDecodes(UIForm.java:203)
               at org.ajax4jsf.component.AjaxViewRoot$1.invokeContextCallback(AjaxViewRoot.java:392)
               at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:238)
               at org.ajax4jsf.component.AjaxViewRoot.processDecodes(AjaxViewRoot.java:409)
               at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:101)
               at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
               at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
               at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
               at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:246)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
               at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
               at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
               at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:365)
               at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
               at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:301)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
               at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
               at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
               at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
               at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
               at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
               at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
               at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
               at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
               at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
               at java.lang.Thread.run(Thread.java:619)
              


              What do I do to remedy this?

              Regards,
              Kashif

              • 4. Re: Problem with rich:fileUpload
                nbelaevski

                Looks like misconfiguration issue. Refer to documentation on how to configure file upload + MyFaces properly.

                • 5. Re: Problem with rich:fileUpload

                  Hi,

                  I did the following configuration after some googling. But the exception is still there.


                  <filter>
                   <display-name>RichFaces Filter</display-name>
                   <filter-name>richfaces</filter-name>
                   <filter-class>org.ajax4jsf.Filter</filter-class>
                   <init-param>
                   <param-name>createTempFiles</param-name>
                   <param-value>true</param-value>
                   </init-param>
                   <init-param>
                   <param-name>maxRequestSize</param-name>
                   <param-value>20000000</param-value>
                   </init-param>
                   </filter>


                  What do I do next. Please help.

                  Regards,
                  Kashif

                  • 6. Re: Problem with rich:fileUpload

                    Hello,

                    I have fixed the exception that was occurring. But now I am facing another problem.

                    byte[] fileData = item.getData();

                    the fileData is null.

                    even though System.out.println(item.getFileName()); is displaying the correct information.

                    What's the problem now?

                    Regards,
                    Kashif

                    • 7. Re: Problem with rich:fileUpload
                      nbelaevski