• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSTL/EL c:if inside of c:forEach

 
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Hey! Wanna see my flashlight? It looks like this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic