Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
590 views
in Technique[技术] by (71.8m points)

file upload - primefaces handleFileUpload doesn't trigger

I'm trying to implement a page with primefaces fileUpload but my handleUpload function isn't triggered. My xhtml:

<h:form enctype="multipart/form-data">
  <p:panel id="uploadFormPanel" header="File upload">
     <h:panelGrid columns="2" style="margin-bottom:10px" cellpadding="5">  
         <h:outputText value="#{criteriaTranslation.questionaireFile}:" />
         <p:fileUpload update="uploadMessages"   
                       fileUploadListener="#{critereCSVImporter.handleFileUpload}"
                       mode="advanced"
                       allowTypes="/(.|/)(csv)$/"/>  
    </h:panelGrid>
    <p:growl id="uploadMessages" showDetail="true"/>
  </p:panel>
</h:form> 

My backing bean:

@ManagedBean
@ViewScoped
public class CritereCSVImporter {

@Inject
private CriteriaBL criteriaBL;
private String OCRMODE;

public void handleFileUpload(FileUploadEvent event) {
    System.out.println("handle");
    InputStream inputStream = event.getFile().getInputstream();
}

My web.xml:

<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>

Am I missing something?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Place commons-fileupload and commons-io jars in your lib folder

Apache Commons FileUpload

Apache Commons IO


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...