JSF error "Expected a child component type ... Found null."

user321068 picture user321068 · Nov 4, 2011 · Viewed 7.3k times · Source

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.

Answer

BalusC picture BalusC · Nov 4, 2011

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.