FileUpload ajax problem

UI Components for JSF
Post Reply
lordpixel
Posts: 134
Joined: 17 Jun 2010, 17:46

16 Jul 2010, 13:04

Hi all I've a little problem with filepuload....
All works fine, i do correctly upload on my remote folder but I can't understand how this component render progress bar.

This is my handler

Code: Select all

public void handleFileUpload(FileUploadEvent event) {
try {

            String nameFile = event.getFile().getFileName();
            //String fileType = event.getFile().getContentType();

            File result = new File(getSessionBean().getPath + nameFile);

            FileOutputStream out = new FileOutputStream(result);

            int BUFFER_SIZE = 8192;
            byte[] buffer = new byte[BUFFER_SIZE];

            int a;
            InputStream is = event.getFile().getInputstream();
            while (true) {
                a = is.read(buffer);
                if (a < 0) {
                    break;
                }
                out.write(buffer, 0, a);
                out.flush();
            }

            out.close();
            is.close();

            
            
        } catch (IOException e) {
            alert.ErroreContext(e.toString());
        }
    }
Now i see that progress bar is complete BEFORE i call my handler.
During the handler i can't lock user interface (for example with a modal dialog using p:dialog and p:ajaxstatus).

Where i'm wrong?

lordpixel
Posts: 134
Joined: 17 Jun 2010, 17:46

16 Jul 2010, 13:11

I forgot to post my upload component

Code: Select all

<p:fileUpload id="UPL_File" fileUploadListener="#{upload.handleFileUpload}"
                              widgetVar="uploader"
                              cancelImage="/resources/cancel.png" customUI="true"
                              multiple="false" update="@form" label="Seleziona File"/>

                <p:commandButton onclick="uploader.upload()" id="BT_Upload" value="Carica File Selezionati"/>

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 32 guests