f:ajax不会在h:inputFile标记内呈现任何内容

时间:2016-02-14 22:34:04

标签: ajax jsf-2.2 mojarra wildfly-10

过去几天我一直困扰着一个我无法解决的问题。我在Mojarra 2.2.12上使用Wildfly 10

我的问题是,当我在f:ajax标记内使用h:inputFile标记并尝试重新呈现任何组件时,使用组件的ID @form,{{1 }或其他任何东西,没有重新渲染。永远。但是,它在@all或其他组件中完全正常。

这是一个简单的例子。

我有一个名为h:commandButton的{​​{1}}文件。此文件包含xhtmlindex.xhtmlh:message

h:inputFile

我还有一个名为h:commandButton的{​​{1}}类,它会根据发生的操作记录消息,并且一旦表单重新生成,就应该在<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:f="http://xmlns.jcp.org/jsf/core"> <h:head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </h:head> <h:body> <h:form id="test" enctype="multipart/form-data"> <h:message for="test" /> <br /> <h:inputFile value="#{uploadController.uploadedFile}"> <f:ajax render=":test" /> </h:inputFile> <h:commandButton value="Push me!" action="#{uploadController.buttonPushed}"> <f:ajax render=":test" /> </h:commandButton> </h:form> </h:body> </html> 标记内显示一条消息渲染的。

ManagedBean

预期的结果是,当您选择文件时,它将“上传”该文件,然后显示“文件已上传!”一旦ajax重新呈现页面,就在UploadController中。然后,如果按下按钮,它将显示“按下按钮!”同样的h:message

实际结果是,是的,“文件已上传”。打印到控制台,但页面永远不会重新呈现,并且消息永远不会出现。另一方面,按钮工作正常,消息就像它应该的那样出现。

我完全不知道该怎么做。我是JSF的初学者。为什么ajax不会在@ManagedBean @ViewScoped public class UploadController { private Part uploadedFile; public Part getUploadedFile() { return uploadedFile; } public void setUploadedFile(Part uploadedFile) { this.uploadedFile = uploadedFile; System.out.println("File Uploaded!"); FacesContext.getCurrentInstance().addMessage("test", new FacesMessage("File Uploaded!")); } public void buttonPushed() { System.out.println("Button pushed!"); FacesContext.getCurrentInstance().addMessage("test", new FacesMessage("Button Pushed!")); } } 内重新渲染,但它在h:message中完全正常?这是一个错误吗?如何在不刷新页面的情况下实现所需的结果?

0 个答案:

没有答案
相关问题