That it works in JSP is meaningless--the two mechanisms are nothing alike. The error message describes exactly what the problem is; you're passing a list, not something that JR can use.
Tragically, I don't actually remember what I did to fix this, although I thought I had changed the plugin to handle that. Perhaps I never checked it in, which would be too bad, because I no longer have access to that code :( Dave On Wed, Feb 16, 2011 at 12:11 PM, Aaron Brown <aa...@thebrownproject.com> wrote: > I'm learning how to use Jasper reports, in this case as a result from > a Struts2 (2.1.8) web app. I'm sending a List (ArrayList) of objects > to a report and when the case is that simple, I have things working > just fine. > > Next, I need to report a hierarchy of data like this example: > List<Parent> parents; > > Parent: > String name; > List<Child> children; > > Child: > String name; > > So I want to send the list of Parent objects to report A. This report > includes a subreport, B, which should iterate over the list of Child > objects for each Parent. Like: > for (Parent p : parents) { > for (Child c : p.children) { > // report > } > } > > My problem is that my report, which compiles cleanly, cannot be > "filled" by the Struts action. I instead get a stack trace about not > being able to evaluate the expression $F{children}, and the end of the > stack trace says: > > Caused by: java.lang.ClassCastException: > org.apache.struts2.views.jasperreports.ValueStackDataSource > incompatible with java.util.List > > I use hibernate and lazy loading on the back end, so I added a loop to > pre-fetch and initialize all the "children" lists for each parent, > just to make sure it wasn't an issue with lazy loading and sessions > and such. The problem still occurs. > > I'm also making sure each "children" ArrayList is either full of data > or initialized as an empty ArrayList, so there should not be any Null > references. > > It appears from the stack trace error that Struts is not allowing > Jasper to access the nested property of the Parent object. I'm doing > the same kind of operation in a dozen places in .jsps, so I know my > object model is solid. > > Does anyone have experience with this kind of Struts 2 reporting in > Jasper who could lend me a hand learning how to do this? > > thanks, > - Aaron > > -- > Aaron Brown : aa...@thebrownproject.com > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org