JSF在视图根中找不到具有表单id的组件

ken*_*jpn 7 java jsf components

我在: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>
Run Code Online (Sandbox Code Playgroud)

在托管bean中:

    private UploadedFile inputFile;
Run Code Online (Sandbox Code Playgroud)

使用Eclipse提供的gets和sets.

//This method scans the view root and returns the component with the id passed as parameter
findComponentInRoot("form:inputFile");
Run Code Online (Sandbox Code Playgroud)

这返回null,但是当我使用时:

   //This method scans the view root and returns the component with the id passed as parameter
    findComponentInRoot("inputFile");
Run Code Online (Sandbox Code Playgroud)

返回是我正在寻找的组件,但是当我在Internet Explorer中使用View Source时,该组件的id是"form:inputFile".

我不知道这是否相关,但组件没有在我的托管bean中设置值,并且奇怪的是组件的id与HTML源不同.我正在使用JSF 1.2 Mojarra.有人有这个问题吗?或者知道为什么会这样?

编辑2:好的,我非常愚蠢,显然构建工作不正常,当构建从Ant更改为其他任务时它工作(仍然不知道为什么,但只是工作).抱歉,添麻烦了.

Boz*_*zho 0

我想findComponentInRoot就是(你应该分享的一个小细节)。

无论如何,使用findComponent(..)getChildren(..)始终返回id页面中定义的组件。html id 是不同的东西,它由naming container:id.