fileUploadListener:prime faces fileUploadListener不调用该方法

时间:2014-04-13 18:40:01

标签: file-upload

我正在使用PrimeFaces 4.0.RC1开发一个Web应用程序,我的文件上传存在问题,

完全使用fileUploadListener;这个监听器没有调用方法" handleFileUpload"。

当我尝试使用commandButton调用此方法时:commandButton中的操作正常工作;

这是我的web.xml:

<!-- Filter for the JSF uploder -->
<context-param>
    <param-name>primefaces.UPLOADER</param-name>
    <param-value>commons</param-value>
</context-param>
<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>facesServlet</servlet-name>
</filter-mapping>

这是我的xhtml页面:

<h:form enctype="multipart/form-data">
<p:growl id="kpiUploadNote" showDetail="true" sticky="true" />

<!-- Test with advanced fileUpload -->
<p:fileUpload
    fileUploadListener="#{fileUploadController.handleFileUpload}"
    mode="advanced" dragDropSupport="false" sizeLimit="100000"
    update="kpiUploadNote" fileLimit="3" allowTypes="/(\.|\/)(csv|xlsx)$/" />

<!-- Test with commandButton to test the bean -->
<p:commandButton action="#{fileUploadController.handleFileUpload}"
    update="kpiUploadNote" ajax="false" />
</h:form>

这是我的ManagedBean:

@Scope
@ManagedBean(name = "fileUploadController")
public class FileUploadController {
    public void handleFileUpload(FileUploadEvent event) {
    System.out.println("calling file upload...");
            FacesMessage msg = new FacesMessage("Succesful",        event.getFile().getFileName() + " is uploaded.");
            FacesContext.getCurrentInstance().addMessage(null, msg);
    }

public void handleFileUpload() {
            FacesMessage msg = new FacesMessage("Succesful", " is uploaded.");
            FacesContext.getCurrentInstance().addMessage(null, msg);
    }
}

这是我的第一个问题,在堆栈溢出,我希望你帮助我:),

0 个答案:

没有答案