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(ListDataModel.java:150)
 at org.apache.myfaces.trinidad.model.SortableModel.getRowData(SortableModel.java:67)
 at org.apache.myfaces.trinidad.model.ChildPropertyTreeModel.getRowData(ChildPropertyTreeModel.java:207)
 at org.apache.myfaces.trinidad.model.ChildPropertyTreeModel.isContainer(ChildPropertyTreeModel.java:219)
 at org.apache.myfaces.trinidad.model.TreeModel.isContainerEmpty(TreeModel.java:153)
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: http://forums.oracle.com/forums/thread.jspa?messageID=5394433

Cheers!