Sunday, November 7, 2010

ADF Faces RC: Resolving javax.faces.model.NoRowAvailableException thrown by <af:tree> Component

Caused by: javax.faces.model.NoRowAvailableException
 at javax.faces.model.ListDataModel.getRowData(
 at org.apache.myfaces.trinidad.model.SortableModel.getRowData(
 at org.apache.myfaces.trinidad.model.ChildPropertyTreeModel.getRowData(
 at org.apache.myfaces.trinidad.model.ChildPropertyTreeModel.isContainer(
 at org.apache.myfaces.trinidad.model.TreeModel.isContainerEmpty(
I have an <af:tree> component which is bound to a tree model that I create programmatically as illustrated in a previous post. The tree component throws the above described error whenever the tree model changes after making disclosure on some nodes. I thought setting the rendered attribute to false whenever the estimatedRowCount is less than 1 would solve the issue, but it did not. Further search made me found the forum post described below that actually resolve the issue.
The solution is to clear the disclosed row keys of the RichTree component whenever there will be changes on the tree model.
    if (richTree != null && richTree.getDisclosedRowKeys()!=null ){
        richTree.getDisclosedRowKeys().clear();//to resolve NoRowAvailableException
Kodus to the collaborators of the following post: