Thread is in continuation of sending-data-back-to-controller-spring-mvc
I am working on a product detail page where I need to show user some options and user will se
the LazyMap factory has to return a LazyList.
the given factory FactoryUtils.instantiateFactory(PrsCDData.class) creates a new PrsCDData object rather than a List of PrsCDData.
prsCDData['Forced'] -> if exists then return it else create instance of PrsCDData.class
should be
prsCDData['Forced'] -> if exists then return it else create instance of LazyList<PrsCDData>
use LazyList since you immediately want to access index '0' what leads to a ArrayIndexOutOfBoundsExecption otherwise
EDIT: Simple example
public class Test {
@SuppressWarnings("unchecked")
public static void main(String[] args) throws UnsupportedEncodingException {
Map<String, List<SimpleBean>> map = MapUtils.lazyMap(new HashMap<String,List<Object>>(),new Factory() {
public Object create() {
return LazyList.decorate(new ArrayList<SimpleBean>(), FactoryUtils.instantiateFactory(SimpleBean.class));
}
});
System.out.println(map.get("test").get(0));
}
public static class SimpleBean {
private String name;
}
}