aspose file tools*
The moose likes Struts and the fly likes Having trouble with options Collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Having trouble with options Collection " Watch "Having trouble with options Collection " New topic
Author

Having trouble with options Collection

Scott Updike
Ranch Hand

Joined: Feb 16, 2006
Posts: 92
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

Joined: Mar 27, 2004
Posts: 401
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 ]

Leandro Melo
SCJP 1.4, SCWCD 1.4
Scott Updike
Ranch Hand

Joined: Feb 16, 2006
Posts: 92
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Having trouble with options Collection
 
Similar Threads
html:select tag - problem in struts
Bad practise? JavaBean where setX() actually should be addX()?
nested JSP
Checkbox on show div tag when the page is loaded
mapping between JSP n form