?
Solved

How to loop through list in jsp using for each and retrieve its properties

Posted on 2014-01-25
2
Medium Priority
?
997 Views
Last Modified: 2014-02-04
Hi, I am having trouble understanding how to retrieve properties out of a collection for display in my jsp page.

I am retrieving a list that is Iterable<company> then putting it into a list in my backing bean

here is the code that is in my backing bean to establish the company name

List<Company> companyFullName = Lists.newArrayList();
Iterable<Company>  owner = Lists.newArrayList();

owner = this.groups.owners().activeAsOf(new YearMonth(this.getMonth())).list();

		for(Company company: owner){
			companyFullName.add(company);
			
		}
		
		super.getContext().putIntoRequest("companyFullName",companyFullName);

Open in new window


Here is the JSP snippet

<c:forEach items="${requestScope.companyFullName}" var="currentCompany" varStatus="loop">
<div class="companyAccordion">
<h3>
	${currentCompany.codeName} - ${currentCompany.commonName}
</h3>

						<div>
							<div class="panelContent"></div>
						</div>
					</div>
				</c:forEach>

Open in new window



This of course isn't working, but I'm not sure what exactly I need to do to get these properties out of the list to use in the header.

Could someone please shed some light on this? Thanks!
0
Comment
Question by:grnmachine
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
Mahesh Bhutkar earned 2000 total points
ID: 39814679
Check out this one,

<c:forEach items="${requestScope.companyFullName}" var="currentCompany">
<div class="companyAccordion">
	<h3>
		<c:out value="${currentCompany.codeName}"/> - <c:out value="${currentCompany.commonName}"/>
	</h3>
	<div>
		<div class="panelContent"></div>
	</div>
</div>
</c:forEach>

Open in new window

0
 

Author Comment

by:grnmachine
ID: 39832714
Thank you for your response, thats what I was looking for.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Suggested Courses
Course of the Month8 days, 8 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question