1 18 19 package org.apache.struts.validator; 20 21 import java.util.Map ; 22 import java.util.List ; 23 import org.apache.commons.beanutils.DynaBean; 24 import org.apache.commons.beanutils.LazyDynaBean; 25 import org.apache.commons.beanutils.LazyDynaMap; 26 27 100 public class LazyValidatorForm extends BeanValidatorForm { 101 102 104 108 public LazyValidatorForm() { 109 super(new LazyDynaBean()); 110 } 111 112 114 public LazyValidatorForm(DynaBean bean) { 115 super(bean); 116 } 117 118 120 128 public Object get(String name, int index) { 129 130 int size = size(name); 131 132 133 Object value = dynaBean.get(name, index); 135 136 if (value == null) { 138 Object indexedValue = dynaBean.get(name); 139 if (List .class.isAssignableFrom(indexedValue.getClass())) { 140 for (int i = size; i <= index; i++) { 141 value = newIndexedBean(name); 142 set(name, i, value); 143 } 144 } 145 } 146 147 return value; 148 149 } 150 151 153 158 public Map getMap() { 159 return ((LazyDynaBean)dynaBean).getMap(); 160 } 161 162 164 172 protected DynaBean newIndexedBean(String name) { 173 return new LazyDynaBean(); 174 } 175 176 } | Popular Tags |