总结之Struts
来源:互联网 发布:多益网络被告新闻 编辑:程序博客网 时间:2024/05/01 17:01
在用Struts的
<logic:iterate id="testqclist" name="testQCActionForm" ="result" indexId="index" >
<bean:write name="testqclist" property="saamsampleid" /> <bean:write name="testqclist" property="sampleid" />
<input type="hidden" name="calcresultVal" value="<bean:write name="testqclist" property="calcresult" />" >
</logic:iterate>
说明:
参数是Property参数
|
indexId:的有个用法是:<logic:iterate i>里面有checkbox的时候,要选择特定的记录数量的时候,可以用到这个属性。
这时要在FORM里添加几个属性
1. 给每个属性添加一个集合属性
2. 添加一个方法保存FORM的对象。返回一个 ArrayList 对象给FORM原有的那个
Result 属性。
在JSP页面里面
每个显示的数据里面都加一个HIDEEN
当提交的时候就可以吧记录保存在FORM里面的集合属性里面。
代码如下
Action:
protected void performDBTask (ActionFormBase actionForm, HttpServletRequest request, HttpServletResponse response ) throws SQLException{ String methodName = "performDBTask()"; //ActinForm TestQCActionForm testQCActionForm = (TestQCActionForm)actionForm; try{ ArrayList handExcel = testQCActionForm.handExcelList(); testQCActionForm.setResultlist(handExcel); actionForm.setForward ("success"); } catch (Exception e){ System.err.println (className + "." + methodName + "==>" + e.getMessage ()); } } |
FORM代码=======================================
private String[] checkboxVal; //Hander Select data public ArrayList handExcelList (){ java.util.ArrayList list = new java.util.ArrayList (); if (checkboxVal != null && checkboxVal.length > 0){ for (int i = 0; i < checkboxVal.length; i++){ int chkVal = Integer.parseInt(checkboxVal[i]); TestQCActionForm checkform = new TestQCActionForm (); checkform.setSaamsampleid (datesampledVal[chkVal].toString()); checkform.setSaamsampleid(saamsampleidVal[chkVal].toString()); checkform.setSampleid (sampleidVal[chkVal].toString()); checkform.setQctypecd (qctypecdVal[chkVal].toString()); checkform.setTestid (testidVal[chkVal].toString()); checkform.setTestseq (testseqVal[chkVal].toString()); checkform.setCalcresult(Double.parseDouble(calcresultVal[chkVal])); checkform.setDatesampled(datesampledVal[chkVal].toString()); list.add (checkform); } } return list; } |
JSP页面===========================================
<lims:notEmpty name="testQCActionForm" property="result"> <logic:iterate id="testqclist" name="testQCActionForm" property="result" indexId="index" > <tr bgcolor="#FFFFFF" onMouseOver="this.bgColor='#ECF4F9'" onMouseOut="this.bgColor='#FFFFFF'"> <td height="26" bgcolor="#EEEEEE"><div align= "center" > <input type="checkbox" name="checkboxVal" value="<%=index%>" > </div></td> <td ><div align="center"> <input type="hidden" name="saamsampleidVal" value="<bean:write name="testqclist" property="saamsampleid" />" > <bean:write name="testqclist" property="saamsampleid" /> </div></td> <td bgcolor="#EEEEEE"><div align="center" > <input type="hidden" name="sampleidVal" value="<bean:write name="testqclist" property="sampleid" />" > <bean:write name="testqclist" property="sampleid" /> </div></td> <td><div align="center"> <input type="hidden" name="qctypecdVal" value="<bean:write name="testqclist" property="qctypecd" />" > <bean:write name="testqclist" property="qctypecd" /> </div></td> <td ><div align="center"> <input type="hidden" name="testidVal" value="<bean:write name="testqclist" property="testid" />" > <bean:write name="testqclist" property="testid" /> </div></td> <td bgcolor="#EEEEEE"><div align="center"> <input type="hidden" name="testseqVal" value="<bean:write name="testqclist" property="testseq" />" > <bean:write name="testqclist" property="testseq" /> </div></td> <td ><div align="center"> <input type="hidden" name="calcresultVal" value="<bean:write name="testqclist" property="calcresult" />" > <bean:write name="testqclist" property="calcresult" /> </div></td> <td ><div align="center"> <input type="hidden" name="datesampledVal" value="<bean:write name="testqclist" property="datesampled" /> " > <bean:write name="testqclist" property="datesampled" /> </div></td> </tr> </logic:iterate> </lims:notEmpty> |
- 总结之Struts
- Struts 原理 之个人总结
- Struts学习总结之配置文件
- 传智播客学习之面试知识点总结struts
- struts总结
- Struts总结
- struts总结
- Struts总结
- struts总结
- struts总结
- struts 总结
- struts总结
- Struts总结
- struts总结
- Struts总结
- struts总结
- struts总结
- Struts总结
- Oracle数据库的备份与恢复
- 今天临时完成的一个将文本格式的文件,转变成XML文件的代码
- 轻松打造Flash帧速率测试器
- JSP(Struts)避免Form重复提交的三种方案
- 如何找工作
- 总结之Struts
- 当今中国流行十大恶习排行榜
- 服务器安装说明
- FreeBSD下安装MySQL+Apache+PHP新手指南
- 写一个登陆用的用户控件。
- 终于又能上网了
- PHP Shell的编写(改进版)
- Advanced Data Access with ADO.NET and Oracle
- 使用递归获取网站下的所有同类型文件