HeideMeister
Jan 27th, 2005, 08:48 AM
Hi
I have a little problem with an application.
The submitted jsp contains a list of items and looks something like this:
<input type="text" name="myListObject[0].myProperty">
<input type="text" name="myListObject[1].myProperty">
<input type="text" name="myListObject[2].myProperty">
The number of items (and thus input fields) varies dynamically.
In my form/command I was planning to do something like this:
private List itemList = new ArrayList();
public MyClass getMyListObject(int index) {
if (itemList.size() <= index) {
for (int i = itemList.size(); i <= index; i++) {
itemList.add(new MyClass());
}
}
return (MyClass) itemList.get(index);
}
(+ getter/setter for the list)
So my form contains a List of MyClass objects, and I was anticipating that
myListObject[0].myProperty
when submitted would result in
getMyListObject(0).setMyProperty(......)
getting called. This does not seem to happen - when the controller (a SimpleFormController) is reached, only an empty list is present.
What am I doing wrong :?:
NOTE: Due to some limitation I'm stuck with Servlet spec. 2.2 and JSP spec. 1.1 - so I can't use any of the Spring tags. [/code]
I have a little problem with an application.
The submitted jsp contains a list of items and looks something like this:
<input type="text" name="myListObject[0].myProperty">
<input type="text" name="myListObject[1].myProperty">
<input type="text" name="myListObject[2].myProperty">
The number of items (and thus input fields) varies dynamically.
In my form/command I was planning to do something like this:
private List itemList = new ArrayList();
public MyClass getMyListObject(int index) {
if (itemList.size() <= index) {
for (int i = itemList.size(); i <= index; i++) {
itemList.add(new MyClass());
}
}
return (MyClass) itemList.get(index);
}
(+ getter/setter for the list)
So my form contains a List of MyClass objects, and I was anticipating that
myListObject[0].myProperty
when submitted would result in
getMyListObject(0).setMyProperty(......)
getting called. This does not seem to happen - when the controller (a SimpleFormController) is reached, only an empty list is present.
What am I doing wrong :?:
NOTE: Due to some limitation I'm stuck with Servlet spec. 2.2 and JSP spec. 1.1 - so I can't use any of the Spring tags. [/code]