3 Replies Latest reply on Feb 9, 2009 3:01 PM by Thomas Marcon

    rich:fileUpload returns

    Thomas Marcon Newbie

      I have a rich:fileUpload component in one of my pages, I want my users to be able to upload a CSV file to the server. Here is the page source :

      <a4j:outputPanel id="ajxBlackList_19">
       <h:inputText id="property_BLACK_LIST" value="#{eventCreation.currentEvent.blackList}" />
      <h:outputText id="houtputText_24" value="Charger les valeurs via un fichier CSV :" />
      <rich:fileUpload id="black_list_upload" fileUploadListener="#{eventCreation.listener}" listHeight="200" immediateUpload="false" acceptedTypes="csv,txt">
       <a4j:support id="a4jsupport_27" event="onuploadcomplete" reRender="ajxBlackList_19" />
      <h:message id="hmessage_29" tooltip="true" for="black_list_upload" style="color: red;" />

      And here is the code of my bean listener (which is never called) :

       private UploadItem csvItem;
       public synchronized void listener(UploadEvent event) {
       this.setCsvItem( event.getUploadItem() );
       // retrieve component id for later use
       UIComponent fromComponent = event.getComponent();
       String componentId = fromComponent.getId();
       String content = null;
       // file reading
       if (getCsvItem().isTempFile()) {
       File csvFile = getCsvItem().getFile();
       StringBuilder fileData = new StringBuilder();
       try {
       BufferedReader reader = new BufferedReader(new FileReader(csvFile));
       char[] buf = new char[1024];
       int numRead=0;
       while((numRead=reader.read(buf)) != -1){
       fileData.append(buf, 0, numRead);
       } catch(Exception e) {
       addErrorMessage(e.getMessage(), componentId);
       content = fileData.toString();
       } else {
       content = new String(getCsvItem().getData());

      Every time I try to upload a file, I get an instant error "Transfer error occured" without my listener being called. I have no trace of any error in a4j log window.

      I put this in my web.xml as suggested :

       <display-name>Ajax4jsf Filter</display-name>

      Anyone has any idea ? Or maybe a way to debug this component so I could know WHY this error occurs ?

      Thanks a lot.