aspose file tools*
The moose likes JSP and the fly likes c:forEach in reverse order Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "c:forEach in reverse order" Watch "c:forEach in reverse order" New topic
Author

c:forEach in reverse order

Dave Brown
Ranch Hand

Joined: Mar 08, 2005
Posts: 301
Hi all,

Anyone know if its possible to specify which direction to run though an ArrayList using forEach. I have a situation where I would like to traverse it from the last element to the first, I dont really want to have to create another list if I have to.

Thanks,

Dave.


Regards, Dave Brown
SCJP 6 - [url]http://www.dbws.net/[/url] - Check out Grails Forum
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60994
    
  65

Not supported.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Call Collections.reverse first


[My Blog]
All roads lead to JavaRanch
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60994
    
  65

Originally posted by Satou kurinosuke:
Call Collections.reverse first


Good point if the original order of the list is not important. Otherwise, a copy will need to be made.

Of course, this cannot be done from the EL so you'd have to do it in the controller when the scoped variable is being set up.
Aji K G
Greenhorn

Joined: Jan 04, 2006
Posts: 1
Use collections instead of array list. So u can do whatever u want using it.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60994
    
  65

"Aji K G",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Additionally, JavaRanch is a community of people from all over the world, many of who are not native English speakers. While using abbreviations like "u" instead of spelling out "you" is convenient when text messaging your friends on a cell phone or in a chat room, it presents an extra challenge to those that are already struggling with English. Additionally, such shortcuts may confound automated translation tools that patrons of the Ranch may be making use of.

I would like to ask for your help in making the content of JavaRanch a little easier to read for everybody that visits here by not using such abbreviations.

Please read this for more information.

thanks,
bear
Forum Bartender
[ January 04, 2006: Message edited by: Bear Bibeault ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60994
    
  65

Originally posted by Aji K G:
Use collections instead of array list.


ArrayList is a Collection.
Dave Brown
Ranch Hand

Joined: Mar 08, 2005
Posts: 301
Ahh a reverse() method, Perfect. Thanks guys.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: c:forEach in reverse order