Struts Version: 2.3.16.3
Is there a way to populate a list of objects without specifying the index? Currently, I am required to reference the collection in this manner:
<input name="myCollection[0].myProperty" value="some value" />
I wish to be able to achieve something like the following:
<input name="myCollection[].myProperty" value="some value" />
As I am dynamically adding and removing elements on the page using JavaScript, it has been challenging to correctly manage the indexing. It would be more convenient if the backend could simply add new elements to the end of the collection as they come across from the form, similar to how PHP handles it.
The documentation for the parameters interceptor suggests that the input name is binding to an OGNL expression. Upon checking the OGNL docs, I found that arrays can be referenced in this way:
array["length"]
This would indicate the next element in the array. However, when attempting this approach, the parameter interceptor indicates rejection of this parameter name. I am eager to discover a solution for this issue, even if it involves extending the parameters interceptor.