4 Replies Latest reply on Sep 5, 2012 11:24 AM by strannik

    Listener of FileUpload is never call

    legalum

      Hi all,

       

      I need your help because i'm stuck with a richface functionnality.

      I'm just trying to set up a simple File upload with the component <rich:FileUpload>, but after reading and following the documentation for this component, the listener from the bean is never call when an upload is finish. and the component display "DONE" when the file is upload.

       

      Debugger don't shows any errors from the code. It's maybe a conflit between SWF and Richfaces.

       

      My configuration :

       

      RichFaces 4.2.0.Final

      SpringMVC

      SpringWebFlow 2.3.0.RELEASE

      JSF 2.0

       

      accueil.xhtml :

       

      <rich:panel>
           <h:form>
                <rich:fileUpload fileUploadListener="#{fileUploadBean.listener}" id="upload" acceptedTypes="jpg, gif, png, bmp" />
            </h:form>
      </rich:panel>
      

       

      flow.xml

       

      <?xml version="1.0" encoding="UTF-8"?>
      <flow xmlns="http://www.springframework.org/schema/webflow"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://www.springframework.org/schema/webflow
              http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
          
          <secured attributes="ROLE_ADMIN,ROLE_FACULTYADMIN,ROLE_CHERCHEUR" match="any"/>
          <persistence-context/>
      
          <view-state id="accueil">
          </view-state>
      </flow>
      

       

      web.xml

       

        <context-param>
          <param-name>org.richfaces.skin</param-name>
          <param-value>blueSky</param-value>
        </context-param>
          <context-param>
              <param-name>org.richfaces.fileUpload.maxRequestSize</param-name>
              <param-value>10000000</param-value>
          </context-param>
          <context-param>
              <param-name>org.richfaces.fileUpload.createTempFiles</param-name>
              <param-value>false</param-value>
          </context-param>
      

       

      ImportCatalogue.java

       

      package com.edhec.faculty.importCatalogue;
      import org.springframework.web.multipart.MultipartFile;
      
      import java.io.FileInputStream;
      import java.io.FileNotFoundException;
      import java.io.IOException;
      import java.io.Serializable;
      import java.text.DateFormat;
      import java.text.SimpleDateFormat;
      import java.util.ArrayList;
      import java.util.Collections;
      import java.util.Date;
      import java.util.List;
      import java.util.Locale;
      import java.util.ResourceBundle;
      
      import javax.faces.bean.ManagedBean;
      import javax.faces.bean.RequestScoped;
      import javax.faces.bean.SessionScoped;
      import javax.faces.bean.ViewScoped;
      import javax.servlet.ServletOutputStream;
      import javax.servlet.http.HttpServletResponse;
      
      import org.richfaces.model.UploadedFile;
      import org.richfaces.event.FileUploadEvent;
      
      import org.apache.poi.hssf.usermodel.HSSFRow;
      import org.apache.poi.hssf.usermodel.HSSFSheet;
      import org.apache.poi.hssf.usermodel.HSSFWorkbook;
      import org.springframework.webflow.execution.Event;
      import org.springframework.webflow.execution.RequestContext;
      import org.apache.poi.poifs.filesystem.*;
      
      @ManagedBean
      @SessionScoped
      public class ImportCatalogue implements Serializable
      {
          private static final long serialVersionUID = 1L;
          
          public void listener(FileUploadEvent event) throws Exception
          {
              System.out.print("test");
              try {
                      POIFSFileSystem inputExcel = new POIFSFileSystem();
                      /*HSSFWorkbook workbook = new HSSFWorkbook(inputExcel);*/
                      
                  } 
              catch (Exception e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
          }
      }
      

       

      Thanks for Helping

        • 1. Re: Listener of FileUpload is never call
          legalum

          Sorry  "ImportCatalogue.listener" instead of  "FileUploadBean.listener" in accueil.xhtml

          • 2. Re: Listener of FileUpload is never call
            strannik

            Hi, Leo

             

            Did you succeed to resolve the issue? This issue happened to me as well.

            My configuration is similar to you. RF 4.2.2, SWF 2.3.1, JSF 2.1.11

             

            My listener method is not invoked. No errors in the log.

            <a4j:log> states(after upload):

             

            debug[12:36:59.693]: richfaces.queue: ajax submit successfull

            debug[12:36:59.695]: richfaces.queue: Nothing to submit

             

            I added fileUpload component to the demo application and the issue reproduced there

            so it looks like integration issue.


            https://issues.jboss.org/browse/RFPL-1430

            • 3. Re: Listener of FileUpload is never call
              strannik

              I added <a4j:log> entry to the showcase application.

              The log is different after upload there

               

               

              debug[12:48:08.970]: richfaces.queue: ajax submit successfull

              debug[12:48:08.971]: richfaces.queue: Nothing to submit

              debug[12:48:08.983]: New request added to queue. Queue requestGroupingId changed to j_idt92:upload

              debug[12:48:08.983]: Queue will wait 0ms before submit

              debug[12:48:08.984]: richfaces.queue: will submit request NOW

              info [12:48:08.986]: Received 'begin' event from <div id=j_idt92:upload class="rf-fu"  ...>

              info [12:48:09.035]: Received 'beforedomupdate' event from <div id=j_idt92:upload class="rf-fu"  ...>

              debug[12:48:09.037]: Server returned responseText: <?xml version='1.0' encoding='UTF-8'?> <partial-response><changes><update id="j_idt92:info"><![CDATA[<div id="j_idt92:info"><div class="rf-p " id="j_idt92:j_idt94"><div class="rf-p-hdr " id="j_idt92:j_idt94_header">Uploaded Files Info</div><div class="rf-p-b info" id="j_idt92:j_idt94_body"><table id="j_idt92:j_idt97" class="rf-dg"><tbody id="j_idt92:j_idt97:dgb" class="rf-dg-body"><tr class="rf-dg-r"><td class="rf-dg-c"><div class="rf-p " id="j_idt92:j_idt97:0:j_idt98"><div class="rf-p-b rich-laguna-panel-no-header" id="j_idt92:j_idt97:0:j_idt98_body"><table> <tbody> <tr> <td><img id="j_idt92:j_idt97:0:j_idt100" src="/richfaces-showcase/rfRes/org.richfaces.resource.MediaOutputResource.jsf?do=eAF1krFrFEEUxl8OrjARiVEMIoHzBEEws4oiwhmQiOjBJSlWRc!q3d7L3hyzO5OZ2ctiVLRQQQsFtQsoaBkr!wshFgErG7URC0VsRCtnd3M5PXDK4Xvf-73vvbWvUE407Lra6GIPmcA4ZAutLgW29ujt5Wfj5pAoAaQKAMpGw86BalZKQRivV!Std6u!v5VgpAnlHoqEnNrCKI8wJK-rKHR1B7O6lC1iQIYFMlIyptgy36Kl81K0SfvYI33lzeuZx6vrcyUoNWBbINCYeYzIwkSO52V4nm81j8NaA0aNq2nnHhb2FAouPZ80R8GvYUtQLVXqX-x6bCkkPfHp-cuft--ddNj1PraG8cF480nUIn137enU2JMPD!oZgFmCm1DOPKfdGMwk8eZQ2WiCrGEk2AUM58h2ZPtsqjQZw2Xs8sveyHYXpoa9RRxOOqxbakyONR9-!J41dGvZ0g2cXty57!9obpzKkRxHVeqQocKgQ1nvYcN6pET9F74XR6!vz5pn!DuW98HkgZVFLuiiEhLbs26RTCGP7Q2A4XPYzPvVxqXPX6ZWzvWjKFnYncfFJVtIrEqsExJG9u8Ui1NSKl0mCDzNg05-At6gtWfQEZLxeBQWMNPFD0s7NhKV08ePHD5xrBI4a0tnpNtebGeq!4GvpuoPgp77VA__&amp;time=1346838489032" style="width:100px; height:100px;" /></td> <td><table> <tbody> <tr> <td>File Name:</td> <td></td> </tr> <tr> <td>File Length(bytes):</td> <td>79569</td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </div></div></td></tr></tbody></table></div></div>  <br /><input id="j_idt92:j_idt108" name="j_idt92:j_idt108" onclick="RichFaces.ajax(&quot;j_idt92:j_idt108&quot;,event,{&quot;incId&quot;:&quot;1&quot;} );return false;" value="Clear Uploaded Data" type="submit" /></div>]]></update><update id="javax.faces.ViewState"><![CDATA[-2912907483053485535:3190918384464476876]]></update></changes></partial-response>

              info [12:48:09.040]: Listing content of response changes element:
              Element update for id=j_idt92:info
              <update id="j_idt92:info"><![CDATA[<div id="j_idt92:info"><div class="rf-p " id="j_idt92:j_idt94"><div class="rf-p-hdr " id="j_idt92:j_idt94_header">Uploaded Files Info</div><div class="rf-p-b info" id="j_idt92:j_idt94_body"><table id="j_idt92:j_idt97" class="rf-dg"><tbody id="j_idt92:j_idt97:dgb" class="rf-dg-body"><tr class="rf-dg-r"><td class="rf-dg-c"><div class="rf-p " id="j_idt92:j_idt97:0:j_idt98"><div class="rf-p-b rich-laguna-panel-no-header" id="j_idt92:j_idt97:0:j_idt98_body"><table> <tbody> <tr> <td><img id="j_idt92:j_idt97:0:j_idt100" src="/richfaces-showcase/rfRes/org.richfaces.resource.MediaOutputResource.jsf?do=eAF1krFrFEEUxl8OrjARiVEMIoHzBEEws4oiwhmQiOjBJSlWRc!q3d7L3hyzO5OZ2ctiVLRQQQsFtQsoaBkr!wshFgErG7URC0VsRCtnd3M5PXDK4Xvf-73vvbWvUE407Lra6GIPmcA4ZAutLgW29ujt5Wfj5pAoAaQKAMpGw86BalZKQRivV!Std6u!v5VgpAnlHoqEnNrCKI8wJK-rKHR1B7O6lC1iQIYFMlIyptgy36Kl81K0SfvYI33lzeuZx6vrcyUoNWBbINCYeYzIwkSO52V4nm81j8NaA0aNq2nnHhb2FAouPZ80R8GvYUtQLVXqX-x6bCkkPfHp-cuft--ddNj1PraG8cF480nUIn137enU2JMPD!oZgFmCm1DOPKfdGMwk8eZQ2WiCrGEk2AUM58h2ZPtsqjQZw2Xs8sveyHYXpoa9RRxOOqxbakyONR9-!J41dGvZ0g2cXty57!9obpzKkRxHVeqQocKgQ1nvYcN6pET9F74XR6!vz5pn!DuW98HkgZVFLuiiEhLbs26RTCGP7Q2A4XPYzPvVxqXPX6ZWzvWjKFnYncfFJVtIrEqsExJG9u8Ui1NSKl0mCDzNg05-At6gtWfQEZLxeBQWMNPFD0s7NhKV08ePHD5xrBI4a0tnpNtebGeq!4GvpuoPgp77VA__&amp;time=1346838489032" style="width:100px; height:100px;" /></td> <td><table> <tbody> <tr> <td>File Name:</td> <td></td> </tr> <tr> <td>File Length(bytes):</td> <td>79569</td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </div></div></td></tr></tbody></table></div></div>  <br /><input id="j_idt92:j_idt108" name="j_idt92:j_idt108" onclick="RichFaces.ajax(&quot;j_idt92:j_idt108&quot;,event,{&quot;incId&quot;:&quot;1&quot;} );return false;" value="Clear Uploaded Data" type="submit" /></div>]]></update>
              Element update for id=javax.faces.ViewState
              <update id="javax.faces.ViewState"><![CDATA[-2912907483053485535:3190918384464476876]]></update>

              debug[12:48:09.044]: richfaces.queue: ajax submit successfull

              debug[12:48:09.045]: richfaces.queue: Nothing to submit

              info [12:48:09.046]: Received 'success' event from <div id=j_idt92:upload class="rf-fu"  ...>

              info [12:48:09.048]: Received 'complete' event from <div id=j_idt92:upload class="rf-fu"  ...>

              • 4. Re: Listener of FileUpload is never call
                strannik

                Looks like known issue and will be fixed in SWF 3.4.0

                 

                https://jira.springsource.org/browse/SWF-1482