I have a command object composed of primitive fields and an object field. How do I bind my form fields to the fields in the object?
I tried doing this but to no ava
Your list either needs to be pre-populated with as many LearningActivity objects as you plan to refer to (using activity[0], activity[1], etc.) or it needs to be a lazy list. A lazy list is a list that will populate itself with empty objects when a given index is referenced.
A comment indicates that you're trying to use Apache Commons LazyList, which ought to work -- are you missing an import directive? However, as an alternative there is a Spring lazy list implementation called AutoPopulatingList.
Two possible issues here:
activity.activity
is invalid (unless your getters do not correspond to your member variables) because Course.activity
is a list. You need to address a particular list element - e.g. activity[0].activity
. You'll also have to make sure it actually exists.
Have you configured your FormController correctly? Does it pass Course
instance to view as it should? Take a look at Spring MVC tutorial for an example.
If after you've fixed #1 and verified that #2 is done correctly the error doesn't go away, please post more details (FormController mapping / source).