aspose file tools*
The moose likes JSF and the fly likes JSTL forEach tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "JSTL forEach tag" Watch "JSTL forEach tag" New topic
Author

JSTL forEach tag

Sakhi Karani
Greenhorn

Joined: Jun 05, 2009
Posts: 4
Hi, Can I use forEach tag with HashSet in items attribute? I am using JSF 1.2 and adding forEach JSTL tag to iterate over the items and display each item in a tab. My backing bean gives me a HashSet in the items attribute. I tried to do it, but my richfaces tab label fails but if I use ArrayList in place of HashSet then everything works fine, along with richfaces.
Where am I going wrong? Please help.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60048
    
  65

Please be sure to ask JSF questions in the JSF forum. I have moved this post there for you.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15632
    
  15

Karani Karani wrote:
Where am I going wrong? Please help.


You're going wrong because you're attempting to sequence through a set of non-sequential data, I think. Easiest way around that is to add a property getter to your backing bean that returns the toArray() method called on the HashSet. However be prepared to see things move around unpredictably if you add or remove elements from the underlying HashSet. If that's not acceptable, you need to trade in your vanilla Set object for something that has a predictable ordering (for example, implements the Comparable interface on ts elements).


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSTL forEach tag
 
Similar Threads
JSTL possibly not recognizing my class because it implents the Map interface
JSTL Question
HashSet in forEach tag
According to TLD or attribute directive in tag file, attribute items does not accept any expressions
Iteration of List in JSP