富表面4.2.3文件上传不调用支持bean方法

时间:2013-05-20 09:30:07

标签: jsf-2 richfaces

我正在尝试使用richfaces文件上传,而fileUploadListener没有在我的backbean中调用监听器。

我的xthml中的代码

 <rich:fileUpload fileUploadListener="#{fileUploadBackingBean.uploadFile}"
                maxFilesQuantity="#{fileUploadBackingBean.uploadsAvailable}"
                id="uploadfls" 
                immediateUpload="#{fileUploadBackingBean.autoUpload}"
                acceptedTypes="pdf,vnd.ms-excel,msexcel,xls" allowFlash="#{fileUploadBackingBean.useFlash}">
</rich:fileUpload>

BackingBean代码

@ManagedBean(name = "fileUploadBean")
public class FileUploadBean {


public void listener(FileUploadEvent event) throws Exception {
    System.out.println("listener");
    }
}

1 个答案:

答案 0 :(得分:1)

如代码所示,绑定到文件上载组件的方法是“uploadFile”,但是您在fileUploadBean中提供的侦听器名称为“listener”。 应该是的, fileUploadListener = “#{fileUploadBean.listener}”

检查以下示例, http://showcase.richfaces.org/richfaces/component-sample.jsf?demo=fileUpload