fileUpload and oncomplete

UI Components for JSF
Post Reply
holek
Posts: 31
Joined: 18 Oct 2011, 16:23

25 Nov 2011, 21:17

Hi,

I'm trying to use oncomplete on fileUpload,
but when file upload ends oncomplete is not fired and js console shows error:
Uncaught TypeError: Cannot call method '_adjustMaxNumberOfFiles' of undefined

Code: Select all

 <p:fileUpload auto="true" allowTypes="#{bean.fileNamePattern}" fileUploadListener="#{bean.uploadFile}" update="@form" oncomplete="alert('test');"/>
is it a bug? any workaround ?

Primefaces 3.0.RC1-SNAPSHOT,
Glassfish 3.1.1

holek
Posts: 31
Joined: 18 Oct 2011, 16:23

30 Nov 2011, 12:56

Hi,
js console shows error only when update attribute is @form

it works on:
IE 9 - IE 9 mode

error is showing on:
Chrome 15.0.874.121 m ( Uncaught TypeError: Cannot call method _adjustMaxNumberOfFiles' of undefined)
Firefox ( b is undefined )
IE 9 - IE 8 mode
IE 9 - IE 7 mode

Full page:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>test</title>
</h:head>
<h:body>
<h:form id="form" enctype="multipart/form-data">
<p:fileUpload auto="true" fileUploadListener="#{test.uploadFile}" update="@form" oncomplete="alert('oncomplete');"/>
</h:form>
</h:body>
</html>

Bean:
import org.primefaces.event.FileUploadEvent;
import org.primefaces.model.UploadedFile;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

@ManagedBean
@ViewScoped
public class Test {
public void uploadFile(FileUploadEvent event) {
UploadedFile uploadedFile = (UploadedFile) event.getFile();
// ...
}

public Test() {
}
}

i've made an issue but it was closed with status CantReplicate: http://code.google.com/p/primefaces/iss ... il?id=2938

What am I doing wrong?

Primefaces 3.0.RC1-SNAPSHOT,
Glassfish 3.1.1, Tomcat 7.0.23

holek
Posts: 31
Joined: 18 Oct 2011, 16:23

01 Dec 2011, 10:51

Hi,

i think I know why file upload shows error ,

when update attribute is @form ( or form id ) primefaces is replacing a form tag with new one,

but form tag is used in fileupload.js ( from trunk ) :

Code: Select all

done: function (e, data) {
                var that = $(this).data('fileupload');
              ...
this code is getting fileupload data value from form ( form = this ) so at the moment of executing function done this value is undefined .

it works only in IE 9 i think,

is this correct?

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 37 guests