• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Having trouble with options Collection

 
Scott Updike
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 [com.product.to.CharelementTO@1b2668f, com.product.to.CharelementTO@16b5d1c]


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.

Scott
 
Leandro Melo
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.

Scott
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic