0

Im using Primefaces4.0 with JSF2.0, i know some basics of Primefaces. For me p:fileUpload is not working, it was working before. don't know what happend when i select any file from the file chooser no file populated in file pan of p:fileUpload.

here is my code:

<p:panel style="font-size:15px;" header="Upload"> 
    <p:fileUpload  fileUploadListener="#{addAgentxls.handleFileUpload}" mode="advanced" dragDropSupport="true"
                   update="messages status" sizeLimit="100000"  style="font-size:12px;" />
    <p:growl id="messages" showDetail="true"/>
    <p:outputLabel id="status" style="font-size:13px;"  value="#{addAgentxls.status }"/>
</p:panel>

class file:

@ManagedBean(name = "addAgentxls", eager = true)
@SessionScoped
public class AddAgentUsingXLS {
    public AddAgentUsingXLS(){
    }
    public void handleFileUpload(FileUploadEvent event) {
           FacesMessage msg = new FacesMessage("Succesful", event.getFile().getFileName() + " is uploaded.");  
           FacesContext.getCurrentInstance().addMessage(null, msg);
        } 
}

web.xml:

<!-- File Uploading Constraints -->
<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>

i also see This done nothing for me there is an error on google chrome browser

Uncaught TypeError: Object [object Object] has no method 'fileupload' 
fileupload.js.xhtml?ln=primefaces&v=4.0:1

does it worth anything?

Community
  • 1
  • 1
Sarz
  • 1,970
  • 4
  • 23
  • 43
  • I am not sure whether you have added enctype="multipart/form-data" to your Form. – psi Mar 26 '14 at 07:25
  • Yup the panel is added in h:form – Sarz Mar 26 '14 at 07:44
  • 1
    Refer http://stackoverflow.com/questions/16166039/uncaught-typeerror-cannot-read-property-value-of-undefined-using-primefaces-f/16168985#16168985 – psi Mar 26 '14 at 08:20
  • thanks @psi that links help BalusC worth it, i was using newer version of jQuery.js – Sarz Mar 27 '14 at 07:28

2 Answers2

1

Solved.. ! i was using newer version of jQuery.js which was conflicting with Primefaces

Sarz
  • 1,970
  • 4
  • 23
  • 43
0

please consider the suggestion on the following stack overflow link.

In JavaScript can I make a "click" event fire programmatically for a file input element?

Same issue. jQuery(".primeFacesHiddenAwayButton type=['file']").click() worked fine on IE as well as firefox ( My firefox is not the latest due to Selenium driver constraints). In any case, in chrome the JS button simply did not work. This is, apparently, a security feature built into the browser. You can try the suggestion on the provided link.

Community
  • 1
  • 1
99Sono
  • 3,554
  • 27
  • 39