JSF error “Expected a child component type … Found null.”

五迷三道 提交于 2019-12-12 11:16:21

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/8008955/jsf-error-expected-a-child-component-type-found-null

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!