Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

c:forEach and beans

 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys

Can I use the core tag c:forEach for iterate over all teh attributes from a bean ? As far as I know I can only iterate over the element from a Collection,Map,array or comma-delimited Strings.


Regards,
M
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can I use the core tag c:forEach for iterate over all teh attributes from a bean ?

No you cannot. The forEach tag is used to iterate through lists of things, not object properties.
 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question is related with the :http://www.coderanch.com/t/176693/java-Web-Component-SCWCD/certification/jsp-useBean
that was the reason why I hijack the thread. In this thread is the following example


in this case the loop will fail ? or not ?

Regards,
M
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why ? It's looping through a Vector, which implements Collection.
 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Christophe you are right, I was a little bit confused by this way of using a bean. I forget to take a look at the bean class.
I was expected that the used class is a classical (set/get bean) - in this case it is not.
With the other words this code snippet does not uses a bean, it uses a vector.
A little bit tricky.

Tanks a lot.
M
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic