public class ShowValueForm extends ActionForm {
/** 上次示数(SCSS),对应的对象属性 */
private double bcss = 0.0D;
//定义一个放n个ShowValueForm的ArrayList
private ArrayList formlst = new ArrayList();
/**
* 上次示数(SCSS),对应的对象属性
* @param scss
*/
public void setBcss(double bcss) {
this.bcss = bcss;
}
/**
* 上次示数(SCSS),对应的对象属性
* @return
*/
public double getBcss() {
return this.sbss;
}
/**
* 返回页面封装的FORM集合。
*/
public ArrayList getFormlst() {
return this.formlst;
}
/**
* 在页面中得到多个form
* @param i:对应页面中的相应的form
* @return
*/
public ShowValueForm getComp(int i) {
if (formlst == null)
formlst = new ArrayList();
if (formlst.size() <= i) {
for (int j = formlst.size(); j <= i; j++)
formlst.add(new ShowValueForm());
}
return (ShowValueForm) formlst.get(i);
}
}
public class ShowValueAction extends DispatchAction{
public ShowValueAction() {
super();
}
/**更新要修改的记录,将返回的结果显示到页面。
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward saveForms(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
{
ActionForward forward = new ActionForward();
ShowValueForm frm = (ShowValueForm) form;
List valuelst = new ArrayList();
String load = request.getParameter("load");
ArrayList updatelst = frm.getFormlst();
//更新并得到更新后的结果
............
return mapping.findForward("savelist");
}
=========================================================================
页面
<html:form action="/showValueInputAction" method="post">
<input type="hidden" name="method" id="method" value="saveForms">
<TABLE cellpadding="0" cellspacing="1">
<TR >
<TH width="80" nowrap>本次示数</TH>
</TR>
<logic:iterate id="item" name="valuelst" scope="request" type="java.util.HashMap" indexId="index">
<TR id="<%=index%>" class="<%=index.intValue() % 2 == 0 ? "dataTable_rowNormal" : "dataTable_rowShadow"%>">
<TD nowrap><input type="text" size="10" name="comp[<%=index%>].bcss" value="<bean:write name="item" property="BCSS" />"></TD>
</TR>
</logic:iterate>
</TABLE>