3.2.0

[no subject]

hello,

i want do add a grid table with a dynamic count of colums, so first of all i try to grep with "rsmd.getColumnName" the columnheaders. in normal html this works fine, but in active grid i always get a pointer something like that: [Ljava.lang.String;@a826da

how can i pass the jsp array to activegrid?


<%@ page import='java.sql.*' %>
<%@ page import='javax.sql.*' %>
<%@ page import='java.util.*' %>
<%@ page import='javax.servlet.*' %>
<%@ page import='javax.servlet.jsp.*' %>
<%@ page import='javax.servlet.http.*' %>
<%@ page import='java.io.*' %>
<%@ page import='java.text.*' %>

<html>
<head>
<title>ActiveWidgets Grid :: Examples</title>
<style> body, html {margin:0px; padding: 0px; overflow: hidden;} </style>

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

<!-- grid format -->
<style>
.active-controls-grid {height: 100%; font: menu;}

.active-column-0 {width: 80px;}
.active-column-1 {width: 200px;}
.active-column-2 {text-align: right;}
.active-column-3 {text-align: right;}
.active-column-4 {text-align: right;}

.active-grid-column {border-right: 1px solid threedlightshadow;}
.active-grid-row {border-bottom: 1px solid threedlightshadow;}
// .active-scroll-bars {overflow: scroll;}
</style>

<!-- grid data -->
<script>

// var myColumns;
// var myData;

</script>
</head>
<body>


<%
String loginUser = "postgres";
String loginPasswd = "postgres";
String loginUrl = "jdbc:postgresql://server02/testdb";
Connection dbcon = null;

try
{
Class.forName("org.postgresql.Driver");
dbcon = DriverManager.getConnection(loginUrl, loginUser, loginPasswd);
}
catch (ClassNotFoundException ex)
{
System.err.println("ClassNotFoundException: " + ex.getMessage());
throw new ServletException("Class not found Error");
}
catch (SQLException ex)
{
System.err.println("SQLException: " + ex.getMessage());
}
// response.setContentType("text/html"); // Response mime type

// Declare our statement
Statement statement = dbcon.createStatement();
String query = "SELECT * FROM biodata";
// Perform the query
ResultSet rs = statement.executeQuery(query);
ResultSetMetaData rsmd = rs.getMetaData();
int n = rsmd.getColumnCount();

String[] myColumnsjsp = new String[n];
String[] myDatajsp = {""};

for( int i=1; i<n; i++ ) {
myColumnsjsp[i] = rsmd.getColumnName( i );
System.out.println( myColumnsjsp[i] );
}
while( rs.next() )
{
for( int i=1; i<n; i++ )
{
// myDatajsp[i] = rs.getString( i );
}
}

%>
<script>

var myColumns = "<%=myColumnsjsp%>";
var myData = "<%=myDatajsp%>";

// create ActiveWidgets Grid javascript object
var obj = new Active.Controls.Grid;

// set number of rows/columns
obj.setRowProperty("count", myData.length);
obj.setColumnProperty("count", myColumns.length);

// provide cells and headers text
obj.setDataProperty("text", function(i, j){return myData[i][j]});
obj.setColumnProperty("text", function(i){return myColumns[i]});

// set headers width/height
obj.setRowHeaderWidth("28px");
obj.setColumnHeaderHeight("20px");
// set click action handler
obj.setAction("click", function(src){window.status = src.getItemProperty("text")});
// for copy 'n' paste only works in IE
obj.setEvent("oncontextmenu", null);
obj.setEvent("onselectstart", null);
// write grid html to the page
document.write(obj);

</script>
</body>
</html>



thanks in advance

marco
marco
June 14,

This topic is archived.

See also:


Back to support forum