This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSTL/EL c:if inside of c:forEach

 
Bryce Martin
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an ArrayList of beans. I set up my forEach like this...



And this works just fine. But now I only want to print the ones that have a ${order.orderType} = 'O'. So I thought I could do something like this...



WDSC says that I can't do tis. It tells me "Missing quotes for attribute value".(refering to test).

Also, is there a way to get the size of the ArrayList? I need to get a value from the last element in the ArrayList...is there an easy way to do that?

[BPSouther: Fixed broken code tag]
[ April 04, 2008: Message edited by: Ben Souther ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64708
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bryce Martin:
WDSC says that I can't do tis. It tells me "Missing quotes for attribute value".(refering to test).
Looks ok to me on first inspection. What's WDSC? An IDE? If so, what happens when you run it outside of the IDE?

Also, is there a way to get the size of the ArrayList?
Check out the fn:length() JSTL function.

I need to get a value from the last element in the ArrayList...is there an easy way to do that?
If you have the index of the item, you can use the EL "array notation".
[ April 04, 2008: Message edited by: Bear Bibeault ]
 
Bryce Martin
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To use the array notation I would have to loop all the way through the ArrayList to capture the last index...I guess I could do that possibly...

Yes, WDSC is an IDE. Its IBM's development studio. WebSphere Development Studio. Its based on Eclipse. I'm not sure what it would do outside of the IDE. We run on WebSphere application servers, so it pretty much stands to bear that if the IDE says its not legal then the App server will throw a fit too. Sucks, but that is what we've got. I'm going to go keep picking away at it.

Thanks.
 
K.Suresh Kumar
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
ArrayList have size() method.It is used to find the size of the ArrayList.

Regards,
Suresh Kumar.K
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64708
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by K.Suresh Kumar:
ArrayList have size() method.It is used to find the size of the ArrayList.
But since it cannot be called using JSTL and EL, that's not useful.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64708
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bryce Martin:
To use the array notation I would have to loop all the way through the ArrayList to capture the last index
No. That's why I mentioned <fn:length()>

I'm not sure what it would do outside of the IDE.
When something that looks like it should work doesn't in an IDE, the first order of business is running it "for real" outside of an IDE. If you don't know how to deploy and run a web app outside of the IDE, that's the next thing to do before you write another line of code.
 
K.Suresh Kumar
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Yes my previous post not helpful for you. But following one definitely helpful for you.

<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
Length of ArrayList is ${fn:length(<your arraylist scoped variable>)}

Regards,
Suresh Kumar.K
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic