Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Having trouble with options Collection

Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been wrestling with this for days and can't seem to make any sense of it. Hopefully I can post my code correctly (with the UBB) for your review. Basically I have a jsp page that will display a drop down list that is populated by a passed bean that contains a property that is an ArrayList of another type of bean.

This is the bean that is passed to the jsp page:

The ArrayList is made up of the following bean:

The jsp page looks like this:

The action code that forwards to this jsp page looks like this:

This errors out with the following error message:

javax.servlet.ServletException: Cannot find bean under name [,]

One interesting thing to note is that if I swap out the html ptions code with the following, it works just fine:

I would like to figure out why I can't get the html ptions tag to work.

Please help with any advice.

Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Scott.

Maybe you have some concepts misunderstood. Some Struts tags contain an property attribute that refers to the name of an specific bean, not to the bean itself. Therefore, it's usual to have something like this in a options tag:

And not this:

Also, you should note that regarding the code you said everything worked, you're not using Struts tags for some cases. For instance, in your pure HTML select tag you're retrieving the charisticbeanname of a scoped object charistic. This is totally fine!

This is also fine when you use it in the items attribute of tag c:forEach, because this attribute actually expects the collection (itself) of elements.

So, I suggest you to pay attention to this details, specially on differences related to the objects and their names, and refactor your code a little bit. Remove the others "${...}" parts of your code and see if it works.
[ June 15, 2007: Message edited by: Leandro Melo ]
Scott Updike
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to your reply, I was able to get this working. It was certainly a misunderstanding on my part of the differences between passing objects vs passing the names of the object.

Thanks again.

And then the entire population worshiped me like unto a god. Well, me and this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic