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
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> map = MapUtils.lazyMap(new HashMap>(),new Factory() {
public Object create() {
return LazyList.decorate(new ArrayList(), FactoryUtils.instantiateFactory(SimpleBean.class));
}
});
System.out.println(map.get("test").get(0));
}
public static class SimpleBean {
private String name;
}
}