Take the 2-minute tour ×

So I'm trying to loop over a List<MyClass> for display in the view of my spring webflow application. However I get the error Must evaluate to a Collection, Map, Array, or null.

	<c:forEach items="#{orderedStuff}" var="a">

I've also tried $ instead of #.

Here is my xml flow definition.

<view-state id="bookToc">
		<evaluate expression="stuffService.getOrderedStuff(stuff)" result="viewScope.orderedStuff"
			result-type="dataModel" />

And the function that returns the list of sections.

public List<Stuff> getStuff(Stuff stuff) {
	final List<Stuff> orderedStuff= new ArrayList<Stuff>();

	final List<Stuff> sections = stuff.getStuff();
	PropertyComparator.sort(sections, new MutableSortDefinition("sortOrder", true, true));

	for (Section stuff : stuffs) {
		this.addSubsectionsToOrderedStuff(stuff, orderedStuff);

	return orderedStuff;

The thing about it is, this code DOES WORK

<h:dataTable id="stuffList" value="#{orderedStuff}" var="s"
    		rendered="#{not empty orderedStuff}">
    			<f:facet name="header">
    				Section Title
    			<h:dataTable value="#{s.chapters}" var="c" rendered="#{not empty s.chapters}">
    					<f:facet name="header">
    					Chapter Title
share|improve this question

2 Answers 2

up vote 1 down vote accepted

I think you would have to call from the scope that you're creating


 <c:forEach items="#{bookTok.orderedStuff}" var="a">

And, why are your lists final?

share|improve this answer
final just means you can't assign a new List to the list (e.g. orderedStuff) reference. That is fine here. –  Matthew Flaschen Jun 15 '09 at 20:52

I guess <c:forEach... needs one of those types. Have you tried converting it to an array, e.g:

// Create an array containing the elements in a list
Stuff[] array = (Stuff[])orderedStuff.toArray(new Stuff[orderedStuff.size()]);

I haven't worked in Java for a while, forgive me if this is way off.

share|improve this answer
isn't ArrayList/List a collection? That's what's confusing me. –  Scott Schulthess Jun 15 '09 at 20:10

Your Answer


