3.2.0

refresh grid

Our developers has developed the following codes for navigator by passing SQL as parameter in tomcat 5.5 web server. But it is not refresh everytime. old data keep in the navigator. please correct the following code


<jsp:include page="getPass.jsp" />
<%@ page import = "java.sql.*" %>
<html>
<head>
<title>Nevigator</title>
<style>body {font: 12px Tahoma}
.headback {
BACKGROUND: #6592ce; FILTER: progid:DXImageTransform.Microsoft.Gradient
(GradientType:0,StartColorStr:'#6592CE',EndColorStr:'#114EA0'); CURSOR: hand; COLOR: #ffffff;font-weight: bold;font-size: 13px
}

</style>

<!-- stylesheet and scripts -->
<link href="runtime/styles/xp/aw.css" rel="stylesheet" type="text/css" ></link>
<script src="runtime/lib/aw.js">

</script>

<!-- grid format -->
<style>
#myGrid {height: 193px; width: 643px;}
#myGrid .aw-row-selector {text-align: center}
#myGrid .aw-column-0 {width: 0px;}
#myGrid .aw-column-1 {width: 0px;}
#myGrid .aw-column-2 {width: 0px;}
#myGrid .aw-column-3{width: 0px;}
#myGrid .aw-column-4 {width: 0px;}
#myGrid .aw-column-5{width: 0px;}
#myGrid .aw-column-6{width: 110px;}
#myGrid .aw-column-7{width: 0px;}
#myGrid .aw-column-8{width: 120px;}
#myGrid .aw-column-9{width: 120px;}
#myGrid .aw-column-10{width: 100px;}
#myGrid .aw-column-11{width: 75px;}
#myGrid .aw-column-12{width: 50px;}
#myGrid .aw-column-13{width: 50px;}
#myGrid .aw-column-14{width: 0px;}
#myGrid .aw-column-15{width: 0px;}
#myGrid .aw-column-2 {text-align: left;}
#myGrid .aw-column-3 {text-align: left;}
#myGrid .aw-column-4 {text-align: left;}
#myGrid .aw-grid-cell {border-right: 1px solid threedlightshadow;}
#myGrid .aw-grid-row {border-bottom: 1px solid threedlightshadow;}

</style>
</head>
<jsp:useBean id="myConn" class="CESCtrackBean.myConnection" scope="application" />
<jsp:useBean id = "execSql" class="CESCtrackBean.executeSql" scope="application"/>
<jsp:useBean id="userValidation" class="CESCtrackBean.userValidation" scope="session" />
<%

Connection conn=myConn.getConnection();
String SQL=request.getParameter("Sql");
String box=request.getParameter("box");
ResultSet Res = execSql.selectRow(conn,SQL);
String empCode = userValidation.getEmp_code();
ResultSetMetaData rsmd=null;
rsmd=Res.getMetaData();
int colCount=rsmd.getColumnCount();
//-- grid column header and type -----------
String cellFormat = "[";
StringBuffer cellHeader = new StringBuffer(1024);
cellHeader.append("[");
for(int i = 1; i<=colCount; i++)
{
System.out.println(rsmd.getColumnTypeName(i));
cellHeader.append("\""+rsmd.getColumnName(i)+"\",");
if(rsmd.getColumnTypeName(i).equals("VARCHAR2"))
cellFormat=cellFormat+"str, ";
if(rsmd.getColumnTypeName(i).equals("NUMBER"))
cellFormat=cellFormat+"num, ";
if(box.equals("R"))
cellFormat=cellFormat+"str, ";
}
System.out.println(cellFormat+"]...............");
cellHeader.setCharAt(cellHeader.length()-1,']');
cellFormat = cellFormat.substring(0,(cellFormat.length()-2)) +"]";
//-- grid data --------------------
StringBuffer cellData=new StringBuffer(1024);

String fieldName = null;
String fieldValue = null;
cellData.append("[");
int rowCount=0;
while(Res.next())
{
cellData.append("[");
int i=1;
for(;i<=(colCount-1);i++)
{
if (Res.getString(i) != null)
{
fieldValue=Res.getString(i);
}
else
{
fieldValue="";
}
cellData.append("\"" + fieldValue + "\", ");
}
if (Res.getString(i) != null)
{
fieldValue=Res.getString(i);
}
else
{
fieldValue="";
}
cellData.append("\"" + fieldValue + "\"], ");
rowCount++;
}
cellData.setCharAt(cellData.length()-1,']');
%>

<body leftmargin="0" topmargin="0">
<table>
<tr>
<%
if(box.equals("I"))
{
%>
<td class="headback" bgcolor="#e8eefa">TO DO LIST...</td>
<%
}
if(box.equals("O"))
{
%>
<td class="headback" bgcolor="#e8eefa">JOB LOOK UP...</td>
<%
}
%>
</tr>
</table>
<script>
//alert("<%=cellFormat%>");
var obj = new AW.UI.Grid;
obj.refresh();
obj.setId("myGrid");
obj.refresh();
// define data formats
var str = new AW.Formats.String;
var num = new AW.Formats.Number;
obj.setCellFormat(<%=cellFormat%>);

// provide cells and headers text
obj.setCellText(<%=cellData%>);
obj.setHeaderText(<%=cellHeader%>);

// set number of rows/columns
obj.setRowCount(<%=rowCount%>);
obj.setColumnCount(<%=colCount%>);

// enable row selectors
obj.setSelectorVisible(true);
obj.setSelectorText(function(i){return this.getRowPosition(i)+1});

// set headers width/height
obj.setSelectorWidth(28);
obj.setHeaderHeight(20);

// set row selection
obj.setSelectionMode("single-row");

// set click action handler
//{window.status = this.getCellText(col, row)}

obj.onCellClicked = function(event, col, row)
{window.status = this.getCellText(col, row)

window.open("sendReply.jsp?tabType="+this.getCellText(0, row)+"&recNo="+this.getCellText(1, row)+"&docket_no="+this.getCellText(2, row)+"&othEmpCode="+this.getCellText(5, row)+"&remarks="+this.getCellText(9, row)+"&navJobNo="+this.getCellText(7, row)+"&description="+this.getCellText(8, row)+"&stageNo="+this.getCellText(14, row)+"&prevStageNo="+this.getCellText(15, row),"ifrmBottom")
window.open("mainMenuLeft.jsp?tabType="+this.getCellText(0, row)+"&recNo="+this.getCellText(1, row)+"&docket_no="+this.getCellText(2, row)+"&othEmpCode="+this.getCellText(5, row)+"&remarks="+this.getCellText(9, row),"ifrmmainMenuLeft")

};


document.write(obj);

</script>

<%


Res.close();
conn.close();
%>
</body>
</html>
Anjan Kundu, universal Solutions, kolkata
January 15,

This topic is archived.

See also:


Back to support forum