0

Imagine you have the following scenario:

  • a property in your action: private Entity entity;
  • Entity has a List<Entity2> entity2List
  • Entity2 has a Entity3 entity3

Now, you need an <s:select> with multiple="true" to populate entity3. This corresponds to having a request in the form entity.entity2List[n].entity3.id (n=0,1,2...depending on how many items are selected).

Question: In the JSP, what should the "name" parameter of the s:select be to achieve this?

I have tried the following without success (meaning entity.entity2List has is empty):

<s:select multiple="true" name="%{entity.entity2List[].entity3.id}" list="#someList" listKey="id" listValue="code"/>
<s:select multiple="true" name="entity.entity2List[].entity3.id" list="#someList" listKey="id" listValue="code"/>
Aleksandr M
  • 24,264
  • 12
  • 69
  • 143
mmalmeida
  • 1,037
  • 9
  • 27
  • I think you should implement custom struts type converter. Name attribute should be written as entity.entity2List. Implement the converter to convert the value to entity2 type object (which in-turn contains entity3). Set the value to id field of entity3 – Rachit Agrawal May 29 '13 at 11:20
  • Use the indexed properties http://stackoverflow.com/questions/15650800/repopulate-an-arraylist-from-jsp-with-struts2/15657572#15657572 – Roman C May 29 '13 at 11:25

0 Answers0