|
这个主题共有 4 回复 / 1 页 [
]
|
|
|
|
|
|
struts多行表单数据读取?
|
发表: 2004年12月22日 11:24
|
回复
|
|
|
我碰到一个问题,如何从多行表单中读取数据.比如在学生录入界面,一次录入10个学生的信息,然后全部读取插入数据库,该如何处理?如果我还要对某些列进行VALIDATOR数据验证,怎样方便的进行呢?
|
|
|
|
|
|
Re: struts多行表单数据读取?
|
发表: 2004年12月22日 12:42
|
回复
|
|
TrustOutClass: public class TrustOutClass { public String goodsID = null; public String goodsName = null; public String purQty = null; public String trustOutQty = null; public String imptPri = null; public String imptAmt = null; public String salePri = null; public String saleAmt = null; ...... } testlistarray: public class testlistarray extends ArrayList { /* * (non-Javadoc) * * @see java.util.List#get(int) */ private Class itemClass; public testlistarray(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); } }
ACTIONFORM: public class F03010 extends ActionForm { ....... private List listarray =new testlistarray(TrustOutClass.class); ....... } ACTION: <logic:iterate id="listarray" name="f03010" property="listarray" indexId="index"> <tr bgcolor=#ffffff> <%-- <td height="20"><div align="left"><html:text name="listarray" property="goodsID" /></div></td> --%> <td height="20"><div align="left"><html:text name="listarray" property="goodsID" /></div></td> <td height="20"><div align="left"><html:text name="listarray" property="goodsName" /></div></td> <td height="20"><div align="right"><html:text name="listarray" property="purQty" /></div></td> <td height="20"><div align="right"><html:text name="listarray" property="trustOutQty" /></div></td> <td height="20"><div align="right"><html:text name="listarray" property="imptPri" /></div></td> <td height="20"><div align="right"><html:text name="listarray" property="imptAmt" /></div></td> <td height="20"><div align="right"><html:text name="listarray" property="salePri" /></div></td> <td height="20"><div align="right"><html:text name="listarray" property="saleAmt" /></div></td> </tr> </logic:iterate>
我们暂不考虑ACTION中的业务逻辑.现在是按这种方法在页面数据有修改后提交,在ACTION中得到的listarray更本就是空的(对象生成了,但是无内容),这让我很费解,如何让我读取界面的数据?
|
|
|
|
|
|
Re: struts多行表单数据读取?
|
发表: 2004年12月22日 12:42
|
回复
|
|
TrustOutClass: public class TrustOutClass { public String goodsID = null; public String goodsName = null; public String purQty = null; public String trustOutQty = null; public String imptPri = null; public String imptAmt = null; public String salePri = null; public String saleAmt = null; ...... } testlistarray: public class testlistarray extends ArrayList { /* * (non-Javadoc) * * @see java.util.List#get(int) */ private Class itemClass; public testlistarray(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); } }
ACTIONFORM: public class F03010 extends ActionForm { ....... private List listarray =new testlistarray(TrustOutClass.class); ....... } ACTION: <logic:iterate id="listarray" name="f03010" property="listarray" indexId="index"> <tr bgcolor=#ffffff> <%-- <td height="20"><div align="left"><html:text name="listarray" property="goodsID" /></div></td> --%> <td height="20"><div align="left"><html:text name="listarray" property="goodsID" /></div></td> <td height="20"><div align="left"><html:text name="listarray" property="goodsName" /></div></td> <td height="20"><div align="right"><html:text name="listarray" property="purQty" /></div></td> <td height="20"><div align="right"><html:text name="listarray" property="trustOutQty" /></div></td> <td height="20"><div align="right"><html:text name="listarray" property="imptPri" /></div></td> <td height="20"><div align="right"><html:text name="listarray" property="imptAmt" /></div></td> <td height="20"><div align="right"><html:text name="listarray" property="salePri" /></div></td> <td height="20"><div align="right"><html:text name="listarray" property="saleAmt" /></div></td> </tr> </logic:iterate>
我们暂不考虑ACTION中的业务逻辑.现在是按这种方法在页面数据有修改后提交,在ACTION中得到的listarray更本就是空的(对象生成了,但是无内容),这让我很费解,如何让我读取界面的数据?
|
|
|
|
|
|
Re: struts多行表单数据读取?
|
发表: 2004年12月22日 12:42
|
回复
|
|
TrustOutClass: public class TrustOutClass { public String goodsID = null; public String goodsName = null; public String purQty = null; public String trustOutQty = null; public String imptPri = null; public String imptAmt = null; public String salePri = null; public String saleAmt = null; ...... } testlistarray: public class testlistarray extends ArrayList { /* * (non-Javadoc) * * @see java.util.List#get(int) */ private Class itemClass; public testlistarray(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); } }
ACTIONFORM: public class F03010 extends ActionForm { ....... private List listarray =new testlistarray(TrustOutClass.class); ....... } ACTION: <logic:iterate id="listarray" name="f03010" property="listarray" indexId="index"> <tr bgcolor=#ffffff> <%-- <td height="20"><div align="left"><html:text name="listarray" property="goodsID" /></div></td> --%> <td height="20"><div align="left"><html:text name="listarray" property="goodsID" /></div></td> <td height="20"><div align="left"><html:text name="listarray" property="goodsName" /></div></td> <td height="20"><div align="right"><html:text name="listarray" property="purQty" /></div></td> <td height="20"><div align="right"><html:text name="listarray" property="trustOutQty" /></div></td> <td height="20"><div align="right"><html:text name="listarray" property="imptPri" /></div></td> <td height="20"><div align="right"><html:text name="listarray" property="imptAmt" /></div></td> <td height="20"><div align="right"><html:text name="listarray" property="salePri" /></div></td> <td height="20"><div align="right"><html:text name="listarray" property="saleAmt" /></div></td> </tr> </logic:iterate>
我们暂不考虑ACTION中的业务逻辑.现在是按这种方法在页面数据有修改后提交,在ACTION中得到的listarray更本就是空的(对象生成了,但是无内容),这让我很费解,如何让我读取界面的数据?
|
|
|
|
|
|
Re: struts多行表单数据读取?
|
发表: 2004年12月22日 12:45
|
回复
|
|
|
|
|
|