Thursday, November 19, 2009

Fixing a little trouble with ADF dynamic menu model

I had to try to troubleshoot something I previously had working in another ADF application without a problem: declaratively-defined dynamic menus. I followed the example given in the 11.2 Using Dynamic Menus for Navigation section of the Oracle® Application Development Framework Developer's Guide
10g (10.1.3.1.0). When I launched my application to check the menus, I was greeted with the infamous 500 Internal Server Error. The exception was:

javax.faces.el.EvaluationException: javax.faces.FacesException: javax.faces.FacesException: Error performing conversion of value 'oracle.adf.view.faces.model.ChildPropertyTreeModel@e38fae' of type 'class oracle.adf.view.faces.model.ChildPropertyTreeModel' to type 'class my.MenuTreeModelAdapter' for managed bean 'menuModel'.

I looked through the whole stack trace for clues, but only the exception message had any glimmer of meaning. I looked at my Java classes and everything looked fine there, too. I poked through all the managed beans holding the pieces of the menu, but nothing jumped out at me.

So I went step by step through the article, comparing its XML and Java code to mine. I had everything in my components the article said to include. After about the fifth iteration of this, I finally started looking at things from a different viewpoint: what was in my code that wasn't in theirs?

Aha! I added a little too much information to one my menuModelAdapter beans. I specified the Java class for the instance property. The bean was supposed to return a ChildPropertyMenuModel object (injected as #{menuTreeModel.model}) and store it in the instance property of the menuModelAdapter object. I mistakenly entered the class as my menuTreeModelAdapter, telling the Faces servlet to convert it, instead of leaving it empty.



I removed the erroneously entered class, leaving the class unspecified, and it resolved my problem. Sometimes it pays to take a moment and look at things from another perspective.