Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

loop inside loop with JSF

 
Antonio Fornie
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all!

I have a list of class Category, and Category has a list of class Product. So I would like to show in my JSP something like this

Category1
Product 1.1
Product 1.2
Product 1.3
Category2
Product 2.1
Product 2.2
Category3
Product 3.1
Product 3.2
Product 3.3

How can I iterate throw categories and for each category iterate throw products with JSF tags? As far as I know I can't use a dataTable inside a dataTable, can I?

Thank you very much!

antonio

 
Tim Holloway
Bartender
Posts: 18423
60
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you can nest datatables.

Technically, however, you don't "loop" in a JSF View, however. The datable is a declaration of how to display collected data, and not, strictly speaking, a logic operation.

I know that this sounds trivial, but one of the most common mistakes people make in JSF is in trying to force the View to act like it's a Controller or Model by slapping logic on it. It's not only counter to the philosophy of JSF, it complicates application maintenance, because it means that you can never be truly certain whether a given bit of logic is in the JSP or the Java code.
 
Antonio Fornie
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much! I'll keep it on mind.

antonio
 
Power corrupts. Absolute power xxxxxxxxxxxxxxxx is kinda neat.
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!