【发布时间】:2011-01-05 13:32:51
【问题描述】:
绑定列表时,我可以通过在 AutoPopulatingList 中使用自定义 ElementFactory 以这种方式控制对象的实例化方式(用于实例调用具有多个参数的构造函数):
public class Foo{
private List<NestedFoo> nested = new AutoPopulatingList<NestedFoo>(new ElementFactory<NestedFoo>() {
@Override
public NestedFoo createElement(int index) throws ElementInstantiationException {
return new NestedFoo(index);
}
});
}
当集合是 Map 而不是 List 时,有什么方法可以做类似的事情吗?我的意思是当表单发送类似 nested['fooParam'] 的内容时,我想在地图“自动增长”时使用 fooParam 调用构造函数。
谢谢。
【问题讨论】:
标签: java spring data-binding collections spring-mvc