How to create a data grid in JSP?

Posted on 2009-04-22
Medium Priority
Last Modified: 2013-11-24
i need to create a data grid to display my datatable. this data grid needs PAGING, sorting functionalities. could you guys help me with that? i am new to JSP/JAVA.

thanks a lot
my class:
public class TA_Transaction
  public Long id;
  public Long ta_InvestorAccId;
  public java.sql.Timestamp eff_date;
  public Double amount;
  public String send_email;
  public Long getTransId()
    return id;
  public Long getTransFromId()
    return ta_InvestorAccId;
  public java.sql.Timestamp getPaymentDate()
    return eff_date;
my form:
  java.util.ArrayList transactions = new java.util.ArrayList ();
  java.util.Vector trans;
  TA_Transaction tran;
//GET all data from database
    com.sr.dblib.Db int_db;
    int_db = new com.sr.dblib.Db(com.sr.dblib.Db.INTRANET_DB);
    String QueryString = "SELECT * from TA_TRANSACTION where ID= 1039162";
    trans =  int_db.SelectObjs(QueryString,TA_Transaction.class);
    for(int i = 0; i < trans.size(); i++)
      tran = (TA_Transaction) trans.get(i);
<form id="main_form" name="main_form">
<table width="100%" cellpadding="0" cellspacing="0" id="formStripe" class="formTable">
         //  the transactions is always empty, i don't know what's going on, where should i put the code which is used to get transactions?
        <c:if test="${empty transactions}">
                  <td colspan="11">No data available</td>
            <c:if test="${!empty transactions}">
              <tr class="formHeader">
//    var="TA_Transaction" : the value of "var " must be the defined class name? or i can use any name?      
              <c:forEach var="TA_Transaction" items="${transactions}">
                  <td><a href="my2ndPage.jsp?id=${TA_Transaction.id}">${TA_Transaction.id}</a></td>
                  <td>${TA_Transaction. eff_date}</td>
// how to do paging and sorting in JSP? PLS HELP ME!!!!

Open in new window

Question by:viola123
  • 3
  • 2
LVL 28

Accepted Solution

rrz earned 2000 total points
ID: 24211865
>//  the transactions is always empty, i don't know what's going on, where should i put the code which is used to get transactions?  

You have defined transactions as a scripting variable.
You could add the following line to the end of your scriptlet.
request.setAttribute("transactions", transactions);
That will create a scoped variable that is available to JSTL.
Alternately, you could create a javabean to hold your db code.  

For paging, you could use third party tags or use JSTL.  See  
LVL 28

Assisted Solution

rrz earned 2000 total points
ID: 24211900
I just noticed that the names of your methods.
>  public Long getTransId()
change that to
  public Long getId()
that way  
will work.  Also  
>public java.sql.Timestamp getPaymentDate()
should be  
public java.sql.Timestamp getEff_date()
>${TA_Transaction. eff_date}
should be  

Please research javabeans and follow the conventions. Life will be easier if you do.
LVL 13

Expert Comment

by:Murali Murugesan
ID: 24212088
use displaytags for this purpose . Its a simple library which provides sorting,paging functionality.

refer this url http://displaytag.sourceforge.net/1.2/

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

LVL 28

Expert Comment

ID: 24215893

Author Comment

ID: 24222085
thanks a lot, i am doing paging now, to see if it works and let you know

thanks heaps

Author Comment

ID: 24257228
sorry to reply late, i was distracted by other stuff. i will post paging issue to another thread.
 thanks a lot

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question