jefmsmit
Feb 1st, 2005, 06:44 PM
I have a command object that contains a list that may be empty. In fact it is always empty when the object is created, not null but empty. The list will only ever contain one item (this is how the object was modeled and it can't be changed), so the UI treats it like its not in a list. Here is the problem, when I go into the form for a create of one of these objects I attempt to bind like this:
<spring:bind path="command.categories[0]">
<!-- My Form Widget Goes Here -->
</spring:bind>
This produces an ArrayIndexOutOfBoundsException because there is no 0 element in the list yet. How can I effectively call the equivalent of getCategories().add with a bind expression. My instinct tells me its not possible and that I should probably use PropertyEditor instead, but I thought I check to see if anyone has something better.
Thanks,
-jeff
<spring:bind path="command.categories[0]">
<!-- My Form Widget Goes Here -->
</spring:bind>
This produces an ArrayIndexOutOfBoundsException because there is no 0 element in the list yet. How can I effectively call the equivalent of getCategories().add with a bind expression. My instinct tells me its not possible and that I should probably use PropertyEditor instead, but I thought I check to see if anyone has something better.
Thanks,
-jeff