Announcement Announcement Module
Collapse
No announcement yet.
c:foreach not working with List Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • c:foreach not working with List

    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.
    Code:
    	
    		<c:forEach items="#{orderedStuff}" var="a">
    		#{a.PrettyName}test
    		</c:forEach>
    I've also tried $ instead of #.


    Here is my xml flow definition.
    Code:
    	<view-state id="bookToc">
    		<on-render>
    			<evaluate expression="stuffService.getOrderedStuff(stuff)" result="viewScope.orderedStuff"
    				result-type="dataModel" />
    		</on-render>
    	</view-state>
    And the function that returns the list of sections.
    Code:
    	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) {
    			orderedStuff.add(stuff);
    			this.addSubsectionsToOrderedStuff(stuff, orderedStuff);
    		}
    		
    		return orderedStuff;
    	}
    The thing about it is, this code DOES WORK


    Code:
        <h:dataTable id="stuffList" value="#{orderedStuff}" var="s"
        			rendered="#{not empty orderedStuff}">
        			<h:column>
        				<f:facet name="header">
        					Section Title
        				</f:facet>
        				#{s.prettyName}
        				<h:dataTable value="#{s.chapters}" var="c" rendered="#{not empty s.chapters}">
        					<h:column>
        						<f:facet name="header">
        						Chapter Title
        						</f:facet>
        					#{c.title}
        					</h:column>
        				</h:dataTable>				
        			</h:column>
        		</h:dataTable>
    Last edited by scottschulthess; Jun 15th, 2009, 04:01 PM.

  • #2
    It isn't a List you are putting in, you are setting the result-type to a dataModel which converts the list into a dataModel usable with JSF.

    Comment

    Working...
    X