I became curious about other experiments.
I found that neither List inside List s, nor Map inside Map (and all interpolations) declared as an interface ( List , Map ), or how their implementations ( ArrayList , HashMap , TreeMap ) are correctly processed by XWork Converter .
All test cases failed.
Perhaps it’s my fault if we really need OGNL experts here, because the whole network says nothing about it.
Then I tried what I was sure it would work: encapsulating this information in user objects , in a pure OOP way.
And it worked :)
Instead
private ArrayList<ArrayList<String>> outerObjects;
you can use in your action
private ArrayList<OuterObject> outerObjects; public ArrayList<OuterObject> getOuterObjects() { return outerObjects; } public void setOuterObjects(ArrayList<OuterObject> outerObjects) { this.outerObjects = outerObjects; }
OuterObject definition:
public class OuterObject{ private ArrayList<InnerObject> innerObjects; public ArrayList<InnerObject> getInnerObjects() { return innerObjects; } public void setInnerObjects(ArrayList<InnerObject> innerObjects) { this.innerObjects = innerObjects; } }
InnerObject definition:
public class InnerObject{ String innerField; public String getInnerField() { return innerField; } public void setInnerField(String innerField) { this.innerField = innerField; } }
an optional execute () method of your Action to check for predefined values:
InnerObject innerObj1 = new InnerObject(); innerObj1.setInnerField("Inner Value 1"); ArrayList<InnerObject> innerObjArrayList = new ArrayList<InnerObject>(); innerObjArrayList.add(innerObj1); OuterObject outerObj1 = new OuterObject(); outerObj1.setInnerObjects(innerObjArrayList); outerObjects = new ArrayList<OuterObject>(); outerObjects.add(outerObj1);
JSP :
<s:form> <s:textfield name="outerObjects[0].innerObjects[0].innerField" /> <s:submit/> </s:form>
(during iteration, just use [%{#stat.index}] for List and ['%{#stat.index}'] for Map s)
The same solution applies for each type of iterative structure (possibly, except for Guava material, which requires the .create() method to be called).
Of course, this is not convenient in every case, in your example you already have a huge structure , and it will almost double it , but it works, it is OOP, your OGNL will be more understandable (because of names) and, nevertheless, it seems the only one way.
Note. Classes must be real autonomous classes, not Inner Classes , in another case where OGNL cannot auto-increment objects.
Hope that helps
EDIT
Then you need only one level:
change this:
private TreeMap<String,List<ObjectC>> allPlainFields;
to that
private TreeMap<String,ObjectX> allPlainFields;
and create an ObjectX containing a private field that is List<ObjectC> .
He will work.