JSF 错误“需要子组件类型...发现 null。”
当使用 RichFaces 示例 在更改下拉框的值时,我总是收到以下错误。
预计子组件类型为 UISelectItem/UISelectItems 组件类型 javax.faces.SelectOne(myId)。发现为空。
这是 JSF 代码:
<h:selectOneMenu id="selectId" valueChangeListener="#{cs.myListener}" value="#{cs.selectList.selectedItem}">
<f:selectItems value="#{cs.bundeslandList.selectItems}" />
<a4j:support event="onchange" reRender="otherFieldId" />
</h:selectOneMenu>
<h:selectOneMenu id="otherFieldId">
<f:selectItems value="#{cs.bundeslandList.selectOtherField.selectItems}" />
</h:selectOneMenu>
由于 cs.bundeslandList.selectOtherField.selectItems
至少是一个空的 ArrayList
,我确信 otherFieldId
不能为null
。
我现在已经删除了整个页面,并且不再收到错误。 valueChangeListener
被正确调用但不幸的是,otherFieldId
在调用后不会刷新。已经空了。但是在调试时我可以看到相应的属性已填充条目。
When using the <a4j:support>
like described in the RichFaces example I'm always getting the following error when changing the value of the drop-down-box.
Expected a child component type of UISelectItem/UISelectItems for
component type javax.faces.SelectOne(myId). Found null.
Here's the JSF code:
<h:selectOneMenu id="selectId" valueChangeListener="#{cs.myListener}" value="#{cs.selectList.selectedItem}">
<f:selectItems value="#{cs.bundeslandList.selectItems}" />
<a4j:support event="onchange" reRender="otherFieldId" />
</h:selectOneMenu>
<h:selectOneMenu id="otherFieldId">
<f:selectItems value="#{cs.bundeslandList.selectOtherField.selectItems}" />
</h:selectOneMenu>
Since cs.bundeslandList.selectOtherField.selectItems
is at least an empty ArrayList
, I'm certain that otherFieldId
can't be null
.
I've stripped down now the whole page and I'm no longer getting the error. The valueChangeListener
is called correctly but unfortunately, the otherFieldId
won't be refreshed after the call. It's emptied. But when debugging I can see that the corresponding property is filled with entries.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
的 getter 在某个时刻肯定返回了null
。此例外没有其他原因。您的支持 bean 代码逻辑流程可能是完全错误的。请注意,将此属性设置为
静态
是一个非常糟糕的主意。它将在整个 Web 应用程序上的所有其他请求之间共享。您希望使其基于请求或基于最高会话。The getter of
<f:selectItems value>
has at some point definitely returnednull
. There's no other reason for this exception. Likely your backing bean code logic flow is plain wrong.Note that making this property
static
is a very bad idea. It's going to be shared among all other requests on the entire web application. You want to make it request based or at highest session based.