【发布时间】:2011-02-04 13:37:57
【问题描述】:
我在表单内有 at:inputFileUpload,在显示页面的 html 中,此组件的 id 是 form:inputFile 但是当我尝试使用“form:inputFile”从视图根目录获取组件时,返回为 null ,但是当“form:”被删除时,返回的是组件。组件没有在我的托管 bean 中设置值,有人有这个问题吗?
编辑:
<h:form id="form" enctype="multipart/form-data">
<t:inputFileUpload id="inputFile" size="40" value="#{managedBean.inputFile}"/>
</h:form>
在托管 bean 中:
private UploadedFile inputFile;
使用 Eclipse 提供的获取和设置。
//This method scans the view root and returns the component with the id passed as parameter
findComponentInRoot("form:inputFile");
这返回null,但是当我使用时:
//This method scans the view root and returns the component with the id passed as parameter
findComponentInRoot("inputFile");
返回的是我正在寻找的组件,但是当我在 Internet Explorer 中使用 View Source 时,该组件的 id 是“form:inputFile”。
我不知道这是否相关,但是组件没有在我的托管 bean 中设置值,而且组件的 id 与 HTML 源代码不同的事实很奇怪。 我正在使用 JSF 1.2 Mojarra。其他人有这个问题吗?或者知道为什么会这样吗?
编辑2: 好的,我很愚蠢,显然构建工作不正常,当构建从 Ant 更改为其他任务时它工作(仍然不知道为什么,但只是工作)。给您添麻烦了。
【问题讨论】:
-
我无法理解你的问题。提供更多细节,最好是代码并改写它。
-
我在表单中有 at:inputFileUpload,组件的值不会进入我的托管 bean,当我尝试从视图根目录获取组件时,组件的 id 不同于页面的 HTML 源代码中显示的内容。
-
你是如何尝试得到它的。正如我所说 - 提供代码!
-
剩下的就是告诉 use
findComponentInRoot是什么。
标签: java jsf components