PDA

View Full Version : String array binding in the command object???


ebrad
Oct 15th, 2007, 01:10 PM
I'm fairly new to Spring and I've been tasked with writing a portlet for Jihia using Spring MVC. Anyway, is there a way to use a String array in my command object and map it to a number of inputs with the same name?

I'm used to using struts and with struts if you had something like this:

<form:input path="qty" />
<form:input path="qty" />
<form:input path="qty" />
<form:input path="qty" />

It would map to a String array in the action form with the name of "qty". How can I do something similar with Spring?

viraj
Oct 15th, 2007, 11:49 PM
Hi,

If you need to bind the array to several text boxes, then you should bind the exact path , like this way.
<form:input path="qty[0]" />
<form:input path="qty[1]" />

where 'qty' is a reference to the array.

-/Viraj

ebrad
Oct 16th, 2007, 02:36 PM
Yeah, I figured it out. I totally overlooked the fact I didn't have my path spelled correctly. Spring resolved it fine and as expected once I did that.