ActionForm:
AutoArrayList
页面上代码:
Action代码:
public List checkResultList = new AutoArrayList(SourceCodeCheckResult.class);
public List getCheckResultList() {
return checkResultList;
}
public void setCheckResultList(List checkResultList) {
this.checkResultList.clear();
this.checkResultList.addAll(checkResultList);
}
AutoArrayList
import java.util.ArrayList;
public class AutoArrayList extends ArrayList {
private Class itemClass;
public AutoArrayList(Class itemClass) {
this.itemClass = itemClass;
}
public Object get(int index) {
try {
while (index >= size()) {
add(itemClass.newInstance());
}
} catch (Exception e) {
e.printStackTrace();
}
return super.get(index);
}
}
页面上代码:
<logic:iterate id="checkResultList" name="requestForm" property="checkResultList" indexId="logId">
<tr>
<td><bean:write property="lineNo" name="checkResultList" /></td>
<td>
<bean:define id="rule" name="checkResultList" property="rule" />
<a href="#" class="clickTip" ruleid='<bean:write property="id" name="rule" />' />
#<bean:write property="id" name="rule" /> <bean:write property="name" name="rule" />
</a>
</td>
<td>
<html:hidden property="logId" name="checkResultList" indexed="true"/>
<html:textarea property="reason" cols="5" rows="10" name="checkResultList" indexed="true"/></td>
<td><html:textarea property="comment" cols="5" rows="10" name="checkResultList" indexed="true"/></td>
<td>
<html:select name="checkResultList" property="reason" onchange="checkHistoryReason()">
<html:option value="">----Please Select one -----</html:option>
<logic:notEmpty property="history" name="checkResultList">
<html:options property="history" name="checkResultList"/>
</logic:notEmpty>
</html:select>
</td>
</tr>
</logic:iterate>
Action代码:
RequestForm requestForm = (RequestForm)form;
List updateData = requestForm.getCheckResultList();
SourceCodeCheckDao dao = (SourceCodeCheckDao) SpringBeanFactory
.getBean(SourceCodeCheckDao.ROLE);
boolean pass = dao.updateCheckRusultList(updateData);