- 论坛徽章:
- 0
|
我现在想把在一个页面上选择后的项目在使用者需要新增的情况下,能够新增而且不丢掉原来已经选择的,我现在用了个笨办法通过两个基本上一样的页面来传递处理的,程序代码大概如下:
<html>;
<%@ page contentType="text/html;charset=gb2312"%>;
...................................
<% ///Variable Define
JCO.Function func1,func2,func3,func4,func5,func6;
JCO.Table pn = null;
JCO.Table pb = null;
JCO.Table basis_weight = null;
JCO.Table size = null;
JCO.Table packaging = null;
JCO.Table _unit = null;
UserSessionData userSessionData = UserSessionData.getUserSessionData(request.getSession());
// --- check session validation
if (userSessionData == null) { response.sendRedirect("../invalidsession.jsp" ; }
BusinessObjectManager bom = (BusinessObjectManager) userSessionData.getBOM(BusinessObjectManager.ISACORE_BOM);
User user = bom.getUser();
String uid = user.getUserId();
String sapFunName = new String();
String temp2 = new String();
int rowNum;
int RowNum = 7;
int iTemp = 0;
String[] index;
if (request.getParameter("rowNum" !=null)
{
rowNum = Integer.parseInt(request.getParameter("rowNum" );
}
String sRow = (String)request.getParameter("num" ;
if (request.getParameter("qutStatu" .equals("no" )
{
RowNum = Integer.parseInt(sRow);
}
else
{
RowNum = Integer.parseInt(sRow);
}
ZRFC_bom myBOM = (ZRFC_bom)userSessionData.getBOM(ZRFC_bom.ZRFC);
ZGetConnection_bo rfc = myBOM.getZGetConnection_bo();
JCoConnection conn = rfc.getConn();
sapFunName = "Z1CRM_GETPAPER";
func1 = conn.getJCoFunction(sapFunName);
func1.getImportParameterList().setValue( "O 50000615", "SALES_ORG" ;
func1.getImportParameterList().setValue( " N", " N_TYPE" ; //PN
pn = func1.getTableParameterList().getTable(" N" ;
try {
conn.execute(func1);
} catch (BackendException ex) { %>; ERROR : Exception ->; <%= ex.toString() %>; <% } %>;
<%
func2 = conn.getJCoFunction("Z1CRM_GETPAPER" ;
func2.getImportParameterList().setValue( "O 50000615", "SALES_ORG");
func2.getImportParameterList().setValue( " B", " N_TYPE");
pb = func2.getTableParameterList().getTable(" N");
try {
conn.execute(func2);
} catch (BackendException ex) { %>; ERROR : Exception ->; <%= ex.toString() %>; <% } %>;
<% func3 = conn.getJCoFunction("Z1CRM_GETPAPER");
func3.getImportParameterList().setValue( "O 50000615", "SALES_ORG");
func3.getImportParameterList().setValue( "GG", " N_TYPE");
basis_weight = func3.getTableParameterList().getTable(" N");
try {
conn.execute(func3);
} catch (BackendException ex) { %>; ERROR : Exception ->; <%= ex.toString() %>; <% } %>;
<% func4 = conn.getJCoFunction(sapFunName);
func4.getImportParameterList().setValue( "O 50000615", "SALES_ORG"); //SIZE
func4.getImportParameterList().setValue( "GG", " N_TYPE");
size = func4.getTableParameterList().getTable(" N");
try {
conn.execute(func4);
} catch (BackendException ex) { %>; ERROR : Exception ->; <%= ex.toString() %>; <% } %>;
<% func5 = conn.getJCoFunction(sapFunName);
func5.getImportParameterList().setValue( "O 50000615", "SALES_ORG"); //packaging
func5.getImportParameterList().setValue( "PACK", "PN_TYPE");
packaging = func5.getTableParameterList().getTable("PN");
try {
conn.execute(func5);
} catch (BackendException ex) { %>; ERROR : Exception ->; <%= ex.toString() %>; <% } %>;
<% func6 = conn.getJCoFunction(sapFunName);
func6.getImportParameterList().setValue( "O 50000615", "SALES_ORG"); //_unit
func6.getImportParameterList().setValue( "UNIT", "PN_TYPE");
_unit = func6.getTableParameterList().getTable("PN");
try {
conn.execute(func6);
} catch (BackendException ex) { %>; ERROR : Exception ->; <%= ex.toString() %>; <% } %>;
<script type="text/javascript">;
var iTmp ;
iTmp = <%= RowNum %>;;
function PostData() {
document.frm.action = "z_postData.jsp";
document.frm.submit();
}
function ChangeNum()
{
if (document.all.num.value >; iTmp )
{
if (document.frm.textfield0.value != "")
{
var i=0;
while ((document.getElementById("textfield"+i)!=null)&&(document.getElementById("textfield"+i).value >; 0))
{
i++;
}
document.frm.rowNum.value=--i;
document.frm.qutStatu.value="yes";
document.frm.method="post";
document.frm.action="z_getPaper1.jsp";
document.frm.target ="_self";
document.frm.submit();
}
else
{
document.frm.qutStatu.value="no";
document.frm.method="post";
document.frm.action="z_getPaper1.jsp";
document.frm.target ="_self";
document.frm.submit();
}
}
else
{
}
}
</script>;
<head>;<meta http-equiv="Content-Type" content="text/html; charset=gb2312">;<style type="text/css">;
<!--
body,td,th {
color: #000000;
}
body {
background-color: #669999;
}
-->;
</style>;
</head>;
<body>;
<%= uid %>;
<hr>;</hr>;
<form name="frm" id="frm" target="_self">;<input name="qutStatu" type="hidden" value="no">;
<p align="left">;Please input inqurit item number: <input name="num" type="text" value="<%= RowNum %>;" size="5" >;
<input type="button" name="change" value="confirm" onClick="ChangeNum()">;
</p>;<input name="rowNum" type="hidden" value="">;
<table width="100%" border="1">;
<tr>;
<th width="13%" scope="col">;SEARCH PN</th>;
<th width="13%" scope="col">;SEARCH PB</th>;
<th width="15%" scope="col">;SEARCH BASIS_WEIGHT</th>;
<th width="10%" scope="col">;SEARCH QUALITY</th>;
<th width= 18%>;SEARCH SIZE</th>;
<th width="11%" scope="col">;SEARCH PACKAGING</th>;
<th width="10%" scope="col">;INPUT QUANTITY</th>;
<th width="10%" scope="col">;INPUT UNIT</th>;
</tr>;
<%
for (int k=0; k < RowNum ; k++)
{
%>;
<tr>;
<td>;<select name="pn<%=k%>;" id="select1" OnChange="">;
<%
for (int i=0; i < pn.getNumRows(); i++)
{
pn.setRow(i);
temp2 = pn.getString("PN_VALUE"); %>;
<option value="<%= pn.getString("PN_VALUE") %>;
<% if ( pn.equals(temp2) ) { %>;" selected>; <% } else { %>; ">; <% } %>;
<%= pn.getString("PN_VALUE") +"-"+ pn.getString("PN_TEXT").trim() %>;</option>;
<% } %>;
</select>;</td>;
<td>;<select name="pb<%=k%>;" id="select2">;
<%
for (int i=0; i < pb.getNumRows(); i++)
{
pb.setRow(i);
temp2 = pb.getString("PN_VALUE"); %>;
<option value="<%= pb.getString("PN_VALUE") %>;
<% if ( pb.equals(temp2) ) { %>;" selected>; <% } else { %>; ">; <% } %>;
<%= pb.getString("PN_VALUE") +"-"+ pb.getString("PN_TEXT") %>;</option>;
<% } %>;
</select>;</td>;
<td>;<select name="basis_weight<%=k%>;" id="select3">;
<%
for (int i=0; i < basis_weight.getNumRows(); i++)
{
basis_weight.setRow(i);
temp2 = basis_weight.getString("PN_VALUE"); %>;
<option value="<%= basis_weight.getString("PN_VALUE") %>;
<% if ( basis_weight.equals(temp2) ) { %>;" selected>; <% } else { %>; ">; <% } %>;
<%= basis_weight.getString("PN_VALUE") +"-"+ basis_weight.getString("PN_TEXT") %>;</option>;
<% } %>;
</select>;</td>;
<td>;<select name="quality<%=k%>;" id="select4">;
<option value="A" selected >;A</option>;
</select>;</td>;
<td>;<select name="size<%=k%>;" id="select">;
<%
for (int i=0; i < size.getNumRows(); i++)
{
size.setRow(i);
temp2 = size.getString("PN_VALUE"); %>;
<option value="<%= size.getString("PN_VALUE") %>;
<% if ( size.equals(temp2) ) { %>;" selected>; <% } else { %>; ">; <% } %>;
<%= size.getString("PN_VALUE") +"-"+ size.getString("PN_TEXT") %>;</option>;
<% } %>;
</select>;</td>;
<td>;<select name="packaging<%=k%>;" id="select6">;
<%
for (int i=0; i < packaging.getNumRows(); i++)
{
packaging.setRow(i);
temp2 = packaging.getString("PN_VALUE"); %>;
<option value="<%= packaging.getString("PN_VALUE") %>;
<% if ( packaging.equals(temp2) ) { %>;" selected>; <% } else { %>; ">; <% } %>;
<%= packaging.getString("PN_VALUE") +"-"+ packaging.getString("PN_TEXT") %>;</option>;
<% } %>;
</select>;</td>;
<td>;<input type="text" name="textfield<%=k%>;" id="textfield<%=k%>;">;</td>;
<td>;<select name="_unit<%=k%>;" id="select7">;
<%
for (int i=0; i < _unit.getNumRows(); i++)
{
_unit.setRow(i);
temp2 = _unit.getString("PN_VALUE"); %>;
<option value="<%= _unit.getString("PN_VALUE") %>;
<% if ( _unit.equals(temp2) ) { %>;" selected>; <% } else { %>; ">; <% } %>;
<%= _unit.getString("PN_VALUE") +"-"+ _unit.getString("PN_TEXT") %>;</option>;
<% } %>;
</select>;</td>;
</tr>;
<% } //endloop%>;
</table>;
<p align="center">;
<input type="button" name="Button1" value="Confirm" onClick="Show()">;
<input type="button" name="Button2" value="Rebuild" onClick="Refresh()" >;
<input type="button" name="submit3" id="submit3" onClick="PostData()" value="Submit">;
</p>;
</form>;
</body>;
</html>;
前一个网页上选择的东西在我增加了新行后传到下个页面要保持住,避免使用者重复前面的劳动,而选择是个客户端的事,事用HTML和JAVASCRIPT上传做的,而传递是通过JSP进行解析的,第二个页面又要通过JAVASCRIPT把前面的还原出来,请高手们指点一下第一个网页该如何发送,而第二个网页该如何实现,请给个DEMO。
谢谢了。!!!!!!!!
急!!!!!!! |
|