What exactly does the code listMilestone[1].status in the html mean?
When you submit an html form, the
struts framework goes through each of the request parameters and tries to set data in the form bean associated with the action to which the submit was made.
Lets say you had a control named "person.address.street" which was submitted in a form. The framework will do the following:
- call the method get
Person() on the form bean
- call the method get
Address() on the object returned from the previous call (i.e. Person)
- call the method set
Street() on the object returned from the previous call (i.e. Address) and set the value of the control "person.address.street".
If any of these methods does not exist, then the framework simply skips to the next request parameter trying to set it, till all request parameters are over.
The important thing to realize over here is that each "get" method call has to return an object otherwise a NullPointerException would be thrown (this is probably what's happening in your case).
For the control named "listMilestone[1].status", something similar happens. Only difference is that the braces "[1]" indicate that the method "get
ListMilestone(int)" will get called. (Just check the link I provided in a previous reply, I remember seeing that the get(int) method returned a List, but I think even the way I suggested would work).
Another important thing to consider is the "scope" of your form bean. If the scope is session, the framework will try to first locate an existing form bean in session and will only create a new one if one does not exist. If the scope is request a new form bean will be created for you each time (I suspect your form bean has scope "request").
Since you want to update information I would suggest keeping the form bean scope as session. If the scope is request, then the form bean constructor would be responsible for ensuring that empty objects are created in the form, thus keeping it ready to be populated. So for the first example, the constructor should create an empty Person object, which has an empty Address object. This gets increasingly complex when you have collections as form attributes. It is much easier to make the form bean scope "session".
Armed with this knowledge, I hope you will be able to debug and fix your problem.
Sheldon Fernandes
