2 Replies Latest reply on Apr 16, 2015 4:44 PM by salma belhaouane

    Rich:fileUpload issue

    salma belhaouane Newbie

      Hi,

       

      I am using Richfaces 4.3, JSF 2.0, Maven and Jboss7.

      I am trying to use <rich:fileUpload> component to upload files.

       

      My code is below:

       

      test.jsf

                      <rich:fileUpload id="fu" acceptedTypes="#{fileUploadBean.acceptedTypes}"

                                     disabled="#{fileUploadBean.disabled}"

                                     fileUploadListener="#{fileUploadBean.listener}"

                                     noDuplicate="#{fileUploadBean.noDuplicate}"

                                     onfilesubmit="onfilesubmit(event)"

                                     onuploadcomplete="onuploadcomplete(event)"

                                     ontyperejected="#{fileUploadBean.ontyperejected}"

                                     onclear="onclear(event)"

                                     onfileselect="onfileselect(event)"

                                     maxFilesQuantity="#{fileUploadBean.maxFilesQuantity}"

                                     immediateUpload="#{fileUploadBean.immediateUpload}"

                              >

                          <a4j:ajax event="uploadcomplete" execute="@none" render="info"/>

                      </rich:fileUpload>

       

       

      FileUploadBean,java

      import org.richfaces.model.UploadedFile;

      import org.richfaces.event.FileUploadEvent;

       

      @ManagedBean(name="fileUploadBean")

      @SessionScoped

      public class FileUploadBean implements Serializable {

          /**

           *

           */

          private static final long serialVersionUID = 1L;

       

       

          private String acceptedTypes = "png";

          private boolean disabled = false;

          private boolean noDuplicate = false;

          private UploadedImage file;

          private List<UploadedImage> files = new ArrayList<UploadedImage>();

          private String clearedFile;

          private String ontyperejected = "alert('typerejected')";

          private Integer maxFilesQuantity = 2;

          private boolean immediateUpload = false;

       

      public void paint(OutputStream stream, Object object) throws IOException {

          stream.write(getFiles().get((Integer) object).getData());

          stream.close();

      }

       

      public void listener(FileUploadEvent event) throws Exception {

          UploadedFile item = event.getUploadedFile();

          file = new UploadedImage();

          file.setLength(item.getData().length);

          file.setName(item.getName());

          file.setData(item.getData());

          files.add(file);

      }

       

      public String clearUploadData() {

          files.clear();

          return null;

      }

       

      public int getSize() {

          if (getFiles().size() > 0) {

              return getFiles().size();

          } else {

              return 0;

          }

      }

       

       

       

       

      //getter & setter

       

      }

       

      web.xml

      <context-param>

           <param-name>org.richfaces.createTempFiles</param-name>

           <param-value>false</param-value>

      </context-param>

      <context-param>

           <param-name>org.richfaces.maxRequestSize</param-name>

           <param-value>100000</param-value>

      </context-param>

       

      When i click on Add, i can browse the files as soon as i select a file nothing happens.

       

      Expected result :

       

       

      The result i get:

      The buttons Add and clear all not displayed.

      the file name and delete ling not displayed (empty box)

       

      Please help!