• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Options Tag not Recognizing Collection

 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Background:

I have a standard JSP page where I pass in a basic transfer object (charistic) that contains a property (charelements) that is an ArrayList of Charelement objects. Each Charelement object contains an element String and and ID which is of type integer.
So in my jsp page I can iterate through the collection with the standard forEach tag without any issue.

c:forEach var="element" items="${charistic.charelements}"

Issue:

However, when I try and build an options tag in the following manner, I get an error (I left out the < and > brackets).

html:select property="${charistic.charisticbeanname}" value="${charistic.invvalue}"

html:options collection="${charistic.charelements}" property="elementID" labelProperty="element"

/html:select


Here is the error:

Cannot find bean under name [com.product.to.CharelementTO@c2060e

I'm not sure why the forEach tag will recognize my collection definition and yet the options tag does not?
 
Sheriff
Posts: 67752
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
Issues with Struts tags should be raised in the Struts forum. I have moved this post there for you.
 
Scott Updike
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let me re-phrase my question a little:

Let's say I am passing to my JSP page one transfer object A which contains a property (called bs) that consists of an ArrayList of transfer objects B. Each of the B transfer objects contain a property (called cs) that consists of an ArrayList of transfer objects C.

So in my JSP page I start iterating through the B transfer objects with the following forEach statement:

forEach items="${A.bs}" var="bs"

Now I'm iterating through the ArrayList of B objects by referencing them by the bs parameter. Within this iteration, I want to iterate through the ArrayList of C objects that are tied to each of the B objects. In the past, I've used a second forEach iteration to iterate through the ArrayList of C objects like this:

forEach items="${bs.cs}" var="cs"

And now I'm able to access/iterate through the ArrayList of C objects that are imbedded within the ArrayList of B objects that is ultimately imbedded in the one A object. I use this second forEach to create a options list HTML element.

What I don't understand is why I can't replace the second forEach with the following code:

select property="${bs.somebeanproperty}"
html ptions collection="${bs.bs}" property="elementID" labelProperty="element"

..where the elementID and element properties have the appropriate setter/getter methods in the C object.

This is the error that I get when I try to use the above code:

Cannot find bean under name [com.product.to.CharelementTO@1747e0f, com.product.to.CharelementTO@100200c]

Where CharelementTO is equivalent to the C object noted above.

So why would the forEach be able to recognize the C ArrayList and not the html ptions (when I use it with the collections property) not recognize it.

Any ideas?
 
Being a smart alec beats the alternative. This tiny ad knows what I'm talking about:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic