:: Forum >> Version 2 >>

how can I convert this code into JSP

More information on this topic is available in the documentation section: /aw.ui.grid/.

How can I convert this code into jsp. Could U plz guide me
Sree
Friday, June 15, 2007
<%@ LANGUAGE = VBscript %>
<%
Dim oConnection
Dim oRecordset

Set oConnection = Server.CreateObject("ADODB.Connection")
oConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("database.mdb")

Set oRecordset = oConnection.Execute("SELECT * FROM table")

function aw_string(s)

s = Replace(s, "\", "\\")
s = Replace(s, """", "\""") 'replace javascript control characters - ", \
rem s = Replace(s, vbCr, "\r")
rem s = Replace(s, vbLf, "\n")

aw_string = """" & s & """"

end function

function aw_headers(oRecordset)

Dim i, count, headers()

count = oRecordset.fields.count
ReDim headers(count-1)

For i=0 to count-1
headers(i) = aw_string(oRecordset(i).name)
Next

Response.write("[" & Join(headers, ", ") & "];")

end function

function aw_cells(oRecordset)

Dim i, col_count, row_count, columns(), rows()

row_count = 0
col_count = oRecordset.fields.count
ReDim columns(col_count-1)

Do while (Not oRecordset.eof)

For i=0 to col_count-1
columns(i) = aw_string(oRecordset(i))
Next

ReDim preserve rows(row_count)

rows(row_count) = vbTab & "[" & Join(columns, ", ") & "]"
row_count = row_count + 1

oRecordset.MoveNext
Loop

Response.write("[" & vbNewLine & Join(rows, "," & vbNewLine) & vbNewLine & "];" & vbNewLine)

end function

%>
<html>
<head>
<script src="../../runtime/lib/aw.js"></script>
<link href="../../runtime/styles/xp/aw.css" rel="stylesheet"></link>
</head>
<body>
<style>

</style>
<script>

// insert javascript arrays produced by ASP functions
var myHeaders = <%= aw_headers(oRecordset) %>
var myCells = <%= aw_cells(oRecordset) %>

// create grid control
var obj = new AW.UI.Grid;

// set grid text
obj.setHeaderText(myHeaders);
obj.setCellText(myCells);

// set number of columns/rows
obj.setColumnCount(myHeaders.length);
obj.setRowCount(myCells.length);

// write grid to the page
document.write(obj);

</script>
</body>
</html>
<%
oRecordset.close
oConnection.close
%>

Sree
Friday, June 15, 2007



This topic is archived.

Back to /aw.ui.grid/

Documentation:

Forum search