FileUpload

UI Components for JSF
Post Reply
rcroonenberghs
Posts: 12
Joined: 14 Jun 2010, 18:28

18 Jul 2011, 16:36

Hi,

I want to use the fileupload component. But when clicking upload, handleFileUpload is not called.
I followed the showcase and the userguide. What am I doing wrong?
(using tomcat 7, primefaces2.2.1, mojarra and richfaces)

Added to xhtml

Code: Select all

<p:fileUpload id="fileupload" fileUploadListener="#{fleetVehicleDetail.handleFileUpload}"   
        allowTypes="*.jpg;*.png;*.gif;" description="Images"/>  
Added to bean

Code: Select all

public void handleFileUpload(FileUploadEvent event) throws IOException, MWSException {
		getLog().info("Uploaded: {}" + event.getFile().getFileName());

		uploadFiles.add(event.getFile());
		FacesMessage msg = new FacesMessage("Succesful", event.getFile().getFileName() + " is uploaded.");
		FacesContext.getCurrentInstance().addMessage(null, msg);
		saveFilesToMiles(0);
	}
Added to web.xml

Code: Select all

<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>
On older code (other page) (legacy) we use the <t:inputFileUpload and that is working correctly. We have an extensionfilter in our web.xml. But when I delete that I get errors when navigating between pages

Code: Select all

<partial-response><changes><update id="javax.faces.ViewState">538047616138701769:1334201969601066705</update></changes><extension primefacesCallbackParam="validationFailed">{"validationFailed":false}</extension></partial-response>

extensionfilter in web.xml

Code: Select all

<filter>
    <filter-name>extensionsFilter</filter-name>
    <filter-class>
			org.apache.myfaces.webapp.filter.ExtensionsFilter
		</filter-class>
    <init-param>
      <description>
				Set the size limit for uploaded files. Format: 10 - 10
				bytes 10k - 10 KB 10m - 10 MB 1g - 1 GB
			</description>
      <param-name>uploadMaxFileSize</param-name>
      <param-value>100m</param-value>
    </init-param>
    <init-param>
      <description>
				Set the threshold size - files below this limit are
				stored in memory, files above this limit are stored on
				disk.

				Format: 10 - 10 bytes 10k - 10 KB 10m - 10 MB 1g - 1 GB
			</description>
      <param-name>uploadThresholdSize</param-name>
      <param-value>100k</param-value>
    </init-param>
  </filter>
  <filter-mapping>
	<filter-name>extensionsFilter</filter-name>
	<servlet-name>Faces Servlet</servlet-name>
  </filter-mapping> 

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 53 guests