Pam Holzner
Pam Holzner

Reputation: 41

Spring Binding issue

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.

Upvotes: 4

Views: 1931

Answers (1)

Yuri.Bulkin
Yuri.Bulkin

Reputation: 1414

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

Upvotes: 2

Related Questions