1

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.

asked Mar 7, 2018 at 13:40
2
  • What is the object types? Commented 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 Class Commented Mar 8, 2018 at 5:51

1 Answer 1

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.

answered Mar 8, 2018 at 12:38
2
  • Is there any way to iterate over LinkedHashSet using struts nested taglib? Commented Mar 8, 2018 at 12:43
  • no, but you can try this solution. Commented Mar 8, 2018 at 12:53

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.