3.2.0

JSP Example?

Is there an example showing how to display a Grid from within a JSP? I ask because I don't see anything displayed in my JSP. If I place the script statements inside an html page it does display properly.
Jerry
May 24,
I found the solution in this forum. It was related to a table with a grid inside of it.
Jerry
May 24,
I am desing webpage which use JSP, I have a example about JSP for you.

<%@ page  language="java" import="java.sql.*"  %>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="control/runtime/styles/xp/grid.css" rel="stylesheet" type="text/css" >
<script src="control/runtime/lib/grid.js"></script>
<script src="control/patches/paging1.js"></script>
<style type="text/css">
<!--
        .active-controls-grid {height:80%; width:100%; font:Arial, Helvetica, sans-serif; background:background-color:#FFFFFF;}
        .active-column-0 {width:40pt; text-align:center; background-color:#FFFFCC;}
        .active-column-1 {width: 110pt; background-color:#CCFFFF;}
        .active-column-2 {width: 60pt; text-align:center; background-color:#FFFFCC;}		
        .active-column-3 {width: 100pt; text-align:center; background-color:#CCFFFF;}
        .active-column-4 {width: 100pt;}		
        .active-column-5 {width: 100pt; text-align:center; background-color:#CCFFFF;}
        .active-grid-column {border-right: 1px solid black;}
        .active-grid-row {border-bottom: 1px solid black;}
        .active-templates-header{font-weight:bold; color:green; text-align:center;}		
-->
</style>
</head>
<%

    try{
        Class.forName("com.mysql.jdbc.Driver");//connect driver
    }
    catch(ClassNotFoundException ce){
        out.print(ce.getMessage());
    }
%>
<body>
<%

    boolean flag = false;
    String datagrid = "var myData=[\n";
                String sConnect = "jdbc:mysql://localhost/YourDB";//I am using MySQL database
                String sUserName = ""; //you define ex: "root"
                String sPassword="";//you define ex: "1234567".. ect 
    try{
        Connection connect = DriverManager.getConnection(sConnect, sUserNam, sPassword);
        ResultSet rs = null;
        Statement st = connect.createStatement();
        rs = st.executeQuery("SELECT * FROM YOURTABLE");
        while(rs.next()){
            if(!flag){
                flag = true;
                datagrid += "[\""+rs.getInt(1)+"\",\""+rs.getString(2)+"\",\""+rs.getString(3)+"\",\""+rs.getString(4)+"\",\""+rs.getString(5)+"\",\""+rs.getString(6)+"\"]\n";
            }
            else{
                datagrid += ",[\""+rs.getInt(1)+"\",\""+rs.getString(2)+"\",\""+rs.getString(3)+"\",\""+rs.getString(4)+"\",\""+rs.getString(5)+"\",\""+rs.getString(6)+"\"]\n";
            }
        }
        datagrid += "];\n";
        rs.close();
        st.close();
        connect.close();
    }
    catch(SQLException se){
        out.print(se.getMessage());
    }
%>
<script>
var myTitle=["Column 1", "Column 2", "Column 3", "Column 4", "Column 5", "Column 6"];
<%=datagrid %>

var obj = new Active.Controls.Grid;
var row = new Active.Templates.Row; //add double click event
row.setEvent("ondblclick", function(){this.action("myAction")}); 
obj.setTemplate("row", row); 
obj.setModel("row", new Active.Rows.Page);
obj.setColumnHeaderHeight(25);	
obj.setProperty("row/count", myData.length-1);//(myData.length-1) is total rows
obj.setProperty("column/count", 6);
obj.setProperty("data/text", function(i, j){return myData[i][j]});
obj.setProperty("column/texts", myTitle);
obj.setProperty("row/pageSize", 25);

document.write(obj);
</script>
</body>
</html>
Ns.Thinh (VietNam)
December 16,


hi,

I used this codings. But I got output only undefined.
Why it is coming like this? What should i do?

If anybody find this solution, Plz send me to the following id:
padhmini83@yahoo.co.in
Padmini
March 15,
Hi frnds actaully im creating one apllication form,i want to add image and i want 2 make it somewat attractive..........can u help me plz

my mail id is s1c9o8r4p2i7o@gmail.com
Niveda.
October 6,
Hi, can we use 2 dimensional arrays(String[row][col]) for the grid control?
Would really appreciate it if anyone can post a sample.

Thank you.

123
dos
October 8,

This topic is archived.

See also:


Back to support forum