1

I am using PF 3.0.RC1 / NetBeans 7.0.1 and when I try to set fileUploadListener for fileUpload component , NetBeans gives this warning "Unknown Property 'handleFileUpload' " at leftmost of line.

In debug mode when I use fileUpload , it don't call handleFileUpload method and nothing becomes.

What can I do for this problem ?

The code in the xhtml page :

 <p:fileUpload fileUploadListener="#{BDS_System.handleFileUpload}" mode="advanced" 
                        sizeLimit="500000" allowTypes="/(\.|\/)(gif|jpe?g|png)$/"/>

The code in the managed bean :

public void handleFileUpload(FileUploadEvent event) {
        String fileName = event.getFile().getFileName();
        byte[] fileBytes = event.getFile().getContents();

        ...
    }

Solved and solution :

Adding

<h:form enctype="multipart/form-data">

and two libraries ,commons-fileupload and commons-io .For maven projects ;

    <dependency>
        <groupId>commons-fileupload</groupId>
        <artifactId> commons-fileupload</artifactId>
        <version>1.2.1</version>
    </dependency>
    <dependency>
        <groupId>commons-io</groupId>
        <artifactId> commons-io</artifactId>
        <version>2.1</version>
    </dependency>
Jman
  • 481
  • 1
  • 4
  • 16

1 Answers1

1

my guess that it is that just like in BalusC answer in this thread: "Unknown Property" the error message of netbeans is nonsense , I think you forgot something in the fileupload config , like the

Getting started with FileUpload

First thing to do is to configure the fileupload filter which parses the multipart request. FileUpload filter should map to Faces Servlet.

<filter>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
</filter-mapping>

and make sure to add enctype to your form like this:

<h:form enctype="multipart/form-data">

if all of the above wont help , take a look at BalusC answer in here: How to use PrimeFaces p:fileUpload

Community
  • 1
  • 1
Daniel
  • 36,833
  • 10
  • 119
  • 200
  • thanks ! I added this and also added two library commons-fileupload and commons-io so it worked :) – Jman Feb 03 '12 at 21:53