如何使用PrimeFaces p:fileUpload?侦听器方法从未被调用我试图使用PrimeFaces上传一个文件,但是fileUploadListener方法在上传完成后不会被调用。以下是观点:<h:form>
<p:fileUpload fileUploadListener="#{fileUploadController.handleFileUpload}"
mode="advanced"
update="messages"
sizeLimit="100000"
allowTypes="/(\.|\/)(gif|jpe?g|png)$/"/>
<p:growl id="messages" showDetail="true"/></h:form>豆子:@ManagedBean@RequestScopedpublic class FileUploadController {
public void handleFileUpload(FileUploadEvent event) {
FacesMessage msg = new FacesMessage("Succesful", event.getFile().getFileName() + " is uploaded.");
FacesContext.getCurrentInstance().addMessage(null, msg);
}}我在这个方法上放置了一个断点,但是它从来没有被调用过。使用时mode="simple"和ajax="false",它被调用,但我希望它在高级模式下工作。我正在使用NetBeans和Glassfish 3.1。
4 回答
牧羊人nacy
TA贡献1862条经验 获得超7个赞
<filter-mapping> <filter-name>PrimeFaces FileUpload Filter</filter-name> <servlet-name>Faces Servlet</servlet-name> <dispatcher>FORWARD</dispatcher></filter-mapping>
一只萌萌小番薯
TA贡献1795条经验 获得超7个赞
<h:form> <p:fileUpload fileUploadListener="#{fileUploadController.handleFileUpload(event)}" mode="advanced" update="messages" sizeLimit="100000" allowTypes="/(\.|\/)(gif|jpe?g|png)$/"/> <p:growl id="messages" showDetail="true"/></h:form>
添加回答
举报
0/150
提交
取消