java Long传值问题_JAVA表格传值问题,求解答。

本文讨论了在Java中处理表格动态数据的JavaScript代码,包括插入、删除表格行及重置索引的功能。同时,展示了Struts框架下的ActionForm类如何接收和处理`Long`类型的PO对象及其详情列表,强调了动态提交数据时的处理方法。
摘要由CSDN通过智能技术生成

展开全部

html代码:

62616964757a686964616fe4b893e5b19e31333335333735

订单行号

工具代码

订货数量

单位编码

需求日期

默认子库

不含税价

实际价格

计划价格

备注

id="00" value="00001" readonly="readonly" />

id="01" οncοntextmenu="return false" οnmοusedοwn="rightclick(event,this)" />

id="02" />

id="03" οncοntextmenu="return false" οnmοusedοwn="rightclick(event,this)" />

id="04" οnclick="return showCalendar(this, '%Y/%m/%d');" />

id="05" />

id="05" />

id="07" />

id="08" />

JS脚本:

//插入表格行

function insertRow()

{

var checks = document.getElementsByName("check");

var t = checks.length;

var i = parseInt(checks[parseInt(t-1)].id, 10) + 1;

var polinenumber;

if (t == 0) {

polinenumber = "00001";

} else {

var prenumber = document.getElementById((i-1).toString() + "0").value;

polinenumber =("00000" + (parseInt(prenumber, 10) + 1).toString()).slice(-5);

}

var detailTable = document.getElementById("detailTable");

var newRow = detailTable.insertRow();

var cell1 = newRow.insertCell();

cell1.innerHTML = '';

var cell2 = newRow.insertCell();

cell2.innerHTML = '';

var cell3 = newRow.insertCell();

cell3.innerHTML = '';

var cell4 = newRow.insertCell();

cell4.innerHTML = '';

var cell5 = newRow.insertCell();

cell5.innerHTML = '';

var cell6 = newRow.insertCell();

cell6.innerHTML = '';

var cell7 = newRow.insertCell();

cell7.innerHTML = '';

var cell8 = newRow.insertCell();

cell8.innerHTML = '';

var cell9 = newRow.insertCell();

cell9.innerHTML = '';

var cell8 = newRow.insertCell();

cell8.innerHTML = '';

var cell9 = newRow.insertCell();

cell9.innerHTML = '';

}

//删除表格行

function deleteRow() {

var detailTable = document.getElementById("detailTable");

var checks = document.getElementsByName("check");

for (var i = checks.length - 1; i >= 0; i--) {

if (checks[i].checked) {

var index = checks[i].parentNode.parentNode.rowIndex;

if (checks.length > 1) {

detailTable.deleteRow(index);

} else {

alert("\u6700\u540e\u4e00\u884c\u4e0d\u80fd\u5220\u9664\uff01\uff01\uff01");

}

}

}

if (checks.length < parseInt(checks[parseInt(checks.length - 1, 10)].id, 10) + 1) {

for (var i = 1; i <= checks.length; i++) {

document.getElementById(checks[i-1].id + "0").value = ("00000" + i.toString()).slice(-5);

}

}

}

//重置索引

function resetIndex()

{

var inputs = document.getElementsByTagName("input");

for(var i=0;i

{

if(inputs[i].name.indexOf('podetails[')!=-1)

{

var index =inputs[i].parentNode.parentNode.rowIndex;

inputs[i].name = inputs[i].name.replace(/\d+/,index-1);

}

}

}

//全选

function checkAll(obj)

{

var checks = document.getElementsByName("check");

for(var i=checks.length-1;i>=0;i--)

{

checks[i].checked = obj.checked;

}

}

后台Java代码:

Form代码:

/*

* Generated by MyEclipse Struts

* Template path: templates/java/JavaClass.vtl

*/

package com.smtcl.business.struts.form;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;

import org.apache.struts.action.ActionForm;

import org.apache.struts.action.ActionMapping;

import com.muhe.tools.AutoArrayList;

import com.smtcl.business.beans.Podetail;

import com.smtcl.business.beans.Po;

/**

* MyEclipse Struts

* Creation date: 09-27-2010

*

* XDoclet definition:

* @struts.form name="poForm"

*/

@SuppressWarnings("unchecked")

public class PoForm extends ActionForm {

/**

*

*/

private static final long serialVersionUID = 1L;

/*

* Generated fields

*/

/** po property */

private Po po = new Po();

/** pod property */

private List podetails = new AutoArrayList(Podetail.class);

/*

* Generated Methods

*/

/**

* Method validate

* @param mapping

* @param request

* @return ActionErrors

*/

public ActionErrors validate(ActionMapping mapping,

HttpServletRequest request) {

// TODO Auto-generated method stub

return null;

}

/**

* Method reset

* @param mapping

* @param request

*/

public void reset(ActionMapping mapping, HttpServletRequest request) {

// TODO Auto-generated method stub

}

public Po getPo() {

return po;

}

public void setPo(Po po) {

this.po = po;

}

public List getPodetails() {

return podetails;

}

public void setPodetails(List podetails) {

this.podetails.clear();

this.podetails = podetails;

}

}

/** po property */

private Po po = new Po();

/** pod property */

private List podetails = new AutoArrayList(Podetail.class);

/*

* Generated Methods

*/

处理动态提交的数据,具体方法根据业务需求自动手做。

public class PoAddAction extends Action {

/*

* Generated Methods

*/

/**

* Method execute

* @param mapping

* @param form

* @param request

* @param response

* @return ActionForward

*/

public ActionForward execute(ActionMapping mapping, ActionForm form,

HttpServletRequest request, HttpServletResponse response) {

PoForm poForm = (PoForm) form;// TODO Auto-generated method stub

com.smtcl.business.beans.Po po = poForm.getPo();

List podetails = poForm.getPodetails();

System.out.println(po.getStorerkey());

System.out.println("------");

System.out.println(podetails.size());

return null;

}

}

2Q==

已赞过

已踩过<

你对这个回答的评价是?

评论

收起

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值