Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSTL Request scope bound List problem  RSS feed

 
K Mansoor
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65825
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Posts: 65825
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And never argue with your mother!!!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!