• 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 Request scope bound List problem

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Folks- I'm stuck with a seemingly very simple problem.
I have a List<MyType> set to the Request from a servlet (actually to the Model in a Spring Controller).

In the JSP/JSTL, I'm trying to create an HTML SELECT/OPTION like this:

This results in the following exception:

I tried a variation; prepended 'param' to the request bound object:

The page is rendered (no exceptions) but neither the <SELECT> is 'disabled' if the list contains only 1 element
nor an <OPTION>--Please select--</OPTION> is added when the list contains more than 1 item. In other words the tests

are never evaluated.

What am I missing? please help.

I tried == and > instead of 'eq' and 'gt' to no avail.
Thanks.
 
Sheriff
Posts: 67750
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

I tried a variation; prepended 'param' to the request bound object:


Randomly trying stuff without understanding it hardly ever works. Just don't. Why would params do anything for you here?

There is no size property on lists. Look at the javadoc. Do you see a getSize() accessor on List? Nope. No accessor == no property.

To get the size of a collection in the EL, use the fn:length() JSTL function.
 
K Mansoor
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As always, it worked! Thank you.

I guess the size() method on List threw me off, didn't realize size will be invoked as getSize.

Randomly trying stuff without understanding it hardly ever works. Just don't.



Bear- I say it with utmost respect, but it sounds like my Mom.
 
Bear Bibeault
Sheriff
Posts: 67750
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
And never argue with your mother!!!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic