f:fileUpdate can't work on showcase

UI Components for JSF
Post Reply
terry.sclaw
Posts: 14
Joined: 23 Aug 2010, 13:22

10 Oct 2010, 07:46

I'm using Glassfish v3 and latest version of primefaces-2.2.RC1-SNAPSHOT (8 Oct 2010).
But the listener still can't work after the file uploaded.

Code: Select all

<p:fileUpload widgetVar="uploader" height="48" width="48"
                                  image="../../resources/images/icons/browse.png" customUI="ture"
                                  fileUploadListener="#{agentInvoiceController.handleFileUpload}" auto="true"
                                  allowTypes="*.xls;" description="Excel" update="growl"/>

Code: Select all

public void handleFileUpload(FileUploadEvent event) {
        JsfUtil.addSuccessMessage(event.getFile().getFileName() + " upload successfully!");
    }

In showcase it seem not work both. The message should be show when the file upload successful.

Who can provide the success code?

Terry

kency
Posts: 65
Joined: 27 Sep 2010, 08:06

10 Oct 2010, 08:07

you can use

Code: Select all

  FacesMessage msg = new FacesMessage("Successful", event.getFile().getFileName() + " was uploaded.");
  FacesContext.getCurrentInstance().addMessage(null, msg);

and in your xhtml page you must have this line

Code: Select all

 <p:growl id="messages" showDetail="true"/>  

and your code fileUpload will be such as:

Code: Select all

<p:fileUpload widgetVar="uploader" height="48" width="48"
                                  image="../../resources/images/icons/browse.png" customUI="ture"
                                  fileUploadListener="#{agentInvoiceController.handleFileUpload}" auto="true"
                                  allowTypes="*.xls;" description="Excel" update="messages"/>

terry.sclaw
Posts: 14
Joined: 23 Aug 2010, 13:22

10 Oct 2010, 13:11

But the listener still can't work after the file uploaded

terry.sclaw
Posts: 14
Joined: 23 Aug 2010, 13:22

10 Oct 2010, 19:39

I tested on windows 7 on localhost, it work! I can find the uploaded file and the fileUploadListener work fine.
But when i deploy to my FreeBSD server, It can't work. It seem can't upload the file to "/var/tmp/" and the fileUploadListener not fire.

Any config missing?

Is permission problem?
***i can create a new file to "/var/tmp"

Code: Select all

            tmpDir = System.getProperty("java.io.tmpdir");
            Boolean success = (new java.io.File(tmpDir + "/fileUpload.txt")).createNewFile();
            if (success) {
                System.out.println("create " + tmpDir + " success!");
            } else {
                System.out.println("create " + tmpDir + " fail!");
            }
Who has same experience?
How can i know the file is successful upload or not?
In version 2.02 is work fine.

Terry
Last edited by terry.sclaw on 11 Oct 2010, 09:47, edited 4 times in total.

kency
Posts: 65
Joined: 27 Sep 2010, 08:06

10 Oct 2010, 19:47


terry.sclaw
Posts: 14
Joined: 23 Aug 2010, 13:22

10 Oct 2010, 20:19

Thanks Kency!
But when i changing the default upload directory, it still can't upload the file.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 41 guests