delnoij
Nov 19th, 2004, 06:54 AM
Hi,
I am having trouble binding form parameters on a bean with a collection property.
My command bean:
public class NewGalleryForm {
private Collection models = new ArrayList();
public Collection getModels() {
return models;
}
public void setModels(Collection models) {
this.models = models;
}
}
The jsp page:
<spring:bind path="iuCommand.models[0].name">
<input type="text" name="name" />
</spring:bind>
For testing purposes, the command object is initialized in the formBackingObject with a collection models containing three Model objects.
Now, when I try to set the name on the Model in the JSP page, it consistently gives null in the controller after submitting the form.
NewGalleryController.onSubmit:
for ( Iterator iter = bean.getModels().iterator(); iter.hasNext();){
Model m = (Model) iter.next();
logger.info("#### model found: " + m);
logger.info("#### model name" + m.getName());
}
Gives:
19 Nov 2004 12:57:46,576 INFO NewGalleryController:45 - onSumbit() called.
19 Nov 2004 12:57:46,586 INFO NewGalleryController:62 - #### model found: com.vvdb.bus.gallery.Model@a262c1
19 Nov 2004 12:57:46,586 INFO NewGalleryController:63 - #### model name null
19 Nov 2004 12:57:46,586 INFO NewGalleryController:62 - #### model found: com.vvdb.bus.gallery.Model@17675
19 Nov 2004 12:57:46,586 INFO NewGalleryController:63 - #### model name null
19 Nov 2004 12:57:46,586 INFO NewGalleryController:62 - #### model found: com.vvdb.bus.gallery.Model@82e1a
19 Nov 2004 12:57:46,586 INFO NewGalleryController:63 - #### model name null
I am using Spring 1.1.
Of course I read this post http://forum.springframework.org/showthread.php?t=10783&highlight=nested+form but I am still stuck, especially because no exception or error is thrown.
Your help is greatly appreciated.
-- Thomas
I am having trouble binding form parameters on a bean with a collection property.
My command bean:
public class NewGalleryForm {
private Collection models = new ArrayList();
public Collection getModels() {
return models;
}
public void setModels(Collection models) {
this.models = models;
}
}
The jsp page:
<spring:bind path="iuCommand.models[0].name">
<input type="text" name="name" />
</spring:bind>
For testing purposes, the command object is initialized in the formBackingObject with a collection models containing three Model objects.
Now, when I try to set the name on the Model in the JSP page, it consistently gives null in the controller after submitting the form.
NewGalleryController.onSubmit:
for ( Iterator iter = bean.getModels().iterator(); iter.hasNext();){
Model m = (Model) iter.next();
logger.info("#### model found: " + m);
logger.info("#### model name" + m.getName());
}
Gives:
19 Nov 2004 12:57:46,576 INFO NewGalleryController:45 - onSumbit() called.
19 Nov 2004 12:57:46,586 INFO NewGalleryController:62 - #### model found: com.vvdb.bus.gallery.Model@a262c1
19 Nov 2004 12:57:46,586 INFO NewGalleryController:63 - #### model name null
19 Nov 2004 12:57:46,586 INFO NewGalleryController:62 - #### model found: com.vvdb.bus.gallery.Model@17675
19 Nov 2004 12:57:46,586 INFO NewGalleryController:63 - #### model name null
19 Nov 2004 12:57:46,586 INFO NewGalleryController:62 - #### model found: com.vvdb.bus.gallery.Model@82e1a
19 Nov 2004 12:57:46,586 INFO NewGalleryController:63 - #### model name null
I am using Spring 1.1.
Of course I read this post http://forum.springframework.org/showthread.php?t=10783&highlight=nested+form but I am still stuck, especially because no exception or error is thrown.
Your help is greatly appreciated.
-- Thomas