发帖    主题    评论    推荐    标签    作者    订阅    查搜    注册   登陆   关注
 
面向对象 设计模式 领域驱动设计 企业架构 框架 开发教程 微服务 CQRS 扩展性 并发编程 事件溯源 分布式 SOA

struts多行表单数据读取?

2004-12-22 11:24
赞助商链接

我碰到一个问题,如何从多行表单中读取数据.比如在学生录入界面,一次录入10个学生的信息,然后全部读取插入数据库,该如何处理?如果我还要对某些列进行VALIDATOR数据验证,怎样方便的进行呢?

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更本就是空的(对象生成了,但是无内容),这让我很费解,如何让我读取界面的数据?

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更本就是空的(对象生成了,但是无内容),这让我很费解,如何让我读取界面的数据?

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更本就是空的(对象生成了,但是无内容),这让我很费解,如何让我读取界面的数据?

2004-12-22 12:45

不好意思,我还以为提交没成功.

赞助商链接

赞助商链接

返回顶部

移动版 关于本站 使用帮助 联系管理员 最佳分辨率1366x768
OpenSource JIVEJDON Powered by JdonFramework Code © 2002-20 jdon.com