I am trying to traverse an ArrayList
and Set
collection objects, using Struts nested tag. I have attached snippet of my code.
<snested:iterate property="productsList" id="aProduct">
<snested:iterate property="participantList" id="participant_item">
......
<snested:text property="firstName" styleClass="text"/>
</snested:iterate>
</snested:iterate>
Here participantList
is Set
and productsList
is List
.
In above code I am getting following error:
Invalid argument looking up property: "productsList[0].participantList[0].firstName" of bean: "orderedProducts"
at org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:887
at org.apache.struts.taglib.html.BaseFieldTag.prepareValue(BaseFieldTag.java:126)
But If I use List
instead of Set
collection it works fine.
-
What is the object types?Roman C– Roman C2018年03月08日 00:24:28 +00:00Commented Mar 8, 2018 at 0:24
-
ArrayList<Product> productsList; and Class Product has a property named Set<ParticipantInfo> participantList and firstName is a property of ParticipantInfo ClassOpu– Opu2018年03月08日 05:51:13 +00:00Commented Mar 8, 2018 at 5:51
1 Answer 1
The class HashSet
is not an indexed collection. You can't use this class with the Struts nested tag.
If the requirement to use Set
instead of List
is mandatory then you should change the tag or tag library used this tag or use another tag library, i.e. JSTL, etc.
-
Is there any way to iterate over LinkedHashSet using struts nested taglib?Opu– Opu2018年03月08日 12:43:33 +00:00Commented Mar 8, 2018 at 12:43
-
lang-java