JSF 错误“需要子组件类型...发现 null。”

发布于 2024-12-13 16:36:10 字数 1091 浏览 4 评论 0原文

当使用 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 otherFieldIdcan'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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

羁客 2024-12-20 16:36:10

的 getter 在某个时刻肯定返回了 null。此例外没有其他原因。您的支持 bean 代码逻辑流程可能是完全错误的。

请注意,将此属性设置为静态是一个非常糟糕的主意。它将在整个 Web 应用程序上的所有其他请求之间共享。您希望使其基于请求或基于最高会话。

The getter of <f:selectItems value> has at some point definitely returned null. 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文