spring - In JSP, Field Path Uses HashMap<String,ArrayList<String>> (SpringMVC Form) -
suppose model field hashmap of strings arraylist's of strings.
hashmap<string,arraylist<string>> map = new hashmap<string,arraylist<string>>(); for field binding, need point i-th item of arraylist of specific key in jsp. how do it? double-bracket notation work? assume 'key' , 'index' known jstl variables in jsp.
<form:checkbox path="map[${key}][${index}]" /> what i'm doing is, field value, store path e.g.
map['testkey'][4] which point to
map.get("testkey").get(4); that doesn't work:
org.springframework.beans.nullvalueinnestedpathexception: invalid property 'map[testkey][0]' note according (binding map of lists in spring mvc), problem because sub-objects not auto-growable, , need implement lazylist or growable list? arraylist growable spring mvc's forms, when used sub-collection, it's not? tricky.
i solved problem following lazylist/lazyset implementation in link above, binding map of lists in spring mvc
from example,
public class prsdata { private map<string, list<prscddata>> prscddata; public prsdata() { this.prscddata = maputils.lazymap(new hashmap<string,list<object>>(), new factory() { public object create() { return lazylist.decorate(new arraylist<prscddata>(), factoryutils.instantiatefactory(prscddata.class)); } }); } } once had data structure mapped jsp path, field binding magically started working , make path e.g. map["key"][index] in jsp.
as replied, springmvc auto-converts simple lists , maps lazy collections, not when collection subobject.
Comments
Post a Comment