tags:

views:

187

answers:

1

Hi, I have some objects like the two below

public class SavedSearch { String title; ArrayList<SearchParameters> params; }

public class SearchParameter { String field; int operator; String match; }

On the JSP page in the input form, I use <input type="text" name="title"> and when I breakpoint inside the FormController, the SavedSearch object has title filled in.

But the ArrayList is always empty. It's not Spring's fault that it can't read my mind, but how do I indicate that field, operator and match are part of params? I tried naming them paramsField, paramsOperator, paramsMatch but no luck.

I know this is not a hard question, but I'm a bit stumped.

Sorry, I forgot to url encode the < and > in the object definition.

+2  A: 

for binding a List you must use special wrapper instead of ArrayList: AutoPopulatingList from Spring or LazyList from Apache Commons Collections.

some examples:

using LazyList

using AutoPopulatingList

Yuri.Bulkin
Thanks. Using LazyList looks very helpful and I will Google AutoPopulatingList and read up on using bind. I had not looked at bind because I'm using 2.5 and I thought that was a pre 2.5 thing, but I will go read up.
Pam Holzner
You may use spring:bind and, for example, form:input in one JSP file, simultaneously. They are very useful for data validation.
Yuri.Bulkin