jsf - Primefaces file upload not working -


this question has answer here:

trying jsf fileuploadlistener work not seem trying printline when hitting {fileuploadview.handlefileupload} nothing seems happening. ui loads fine on localhost:8080/index.jsf after clicking on choose file select file after pressing upload button nothing happens no errors in logs or print lines printing display point of view seems fine.

index.xhtml

    <!doctype html>     <html xmlns="http://www.w3.org/1999/xhtml"           xmlns:h="http://xmlns.jcp.org/jsf/html"           xmlns:ui="http://xmlns.jcp.org/jsf/facelets"           xmlns:f="http://xmlns.jcp.org/jsf/core"           xmlns:p="http://primefaces.org/ui">          <link type="text/css" rel="stylesheet" href="/project/faces/javax.faces.resource/theme.css?ln=primefaces-glass-x" />          <f:view>             <h:head>                 <meta charset="utf-8" />                  <title>test</title>             </h:head>               <h:body>                 <h:form>                     <p:fileupload fileuploadlistener="#{fileuploadview.handlefileupload}" mode="advanced" dragdropsupport="true"                                   update="messages" sizelimit="100000" allowtypes="/(\.|\/)(gif|jpe?g|png)$/" />                      <p:growl id="messages" showdetail="true" />                 </h:form>             </h:body>         </f:view>     </html> 

fileuploadview.java (bean)

import javax.faces.application.facesmessage; import javax.faces.bean.managedbean; import javax.faces.bean.viewscoped; import javax.faces.context.facescontext;  import org.primefaces.event.fileuploadevent; import org.primefaces.model.uploadedfile;  @managedbean @viewscoped public class fileuploadview {      private uploadedfile uploadedfile;      public void handlefileupload(fileuploadevent event) {         system.out.println("handel file upoad =-=-=-=-=-");         facesmessage message = new facesmessage("succesful", event.getfile().getfilename() + " uploaded.");         facescontext.getcurrentinstance().addmessage(null, message);     }      public uploadedfile getuploadedfile() {         system.out.println("uploading file =-=-=-=");         return uploadedfile;     }      public void setuploadedfile(uploadedfile uploadedfile) {                 system.out.println("uploading file set =-=-=-=");          this.uploadedfile = uploadedfile;     }   } 

add enctype in form.

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

Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -