Click here to Skip to main content
Click here to Skip to main content

Data Grid for JSP

By , 21 Jul 2006
 

Sample Image - DBGrid.png

Introduction

This article presents a Grid control very similar to the one found in ASP.NET, but for JSP pages. Although a data grid can be easily rendered using JSTL for loop tag, it tends to clutter the code and hence debugging can become very difficult. The control presented in this article makes coding such grids a breeze and also it helps one to keep the code clean.

Features at a glance

At present the control implements following things.

  • Data pagination.
  • Sorting by a specified column.
  • Automatic row number display.
  • Image based hyperlink columns.
  • Hyperlink columns.
  • Custom data formatting.
  • Value decoding.
  • Ability to bind to a List.
  • Ability to bind to a ResultSet.
  • Ability to bind to a RowSet.

Apart from this it also allows one to specify column names to be used while constructing the HREF element of the hyperlink. This reference then at runtime automatically gets substituted by the column value. For example the following code snippet

<grd:imagecolumn headerText="" width="5" HAlign="center" imageSrc="images/Edit.gif" 
    linkUrl="javascript:doEdit('{CLICORPORATION}', '{CLICLIENT}')" imageBorder="0" 
    imageWidth="16" imageHeight="16" alterText="Click to edit"></grd:imagecolumn>
results in following code to be outputted to the browser
<td WIDTH="5%" ALIGN="center">
    <a HREF="javascript:doEdit('TATA', 'TELCO')">
        <img SRC="images/Edit.gif" BORDER=0 WIDTH=16 HEIGHT=16 ALT="Click to edit">
    </a>
</td>

The Control Details

The DBGrid control consists of following sub controls (classes).

  1. gridpager - This control is responsible for rendering the pager control. This control has following attributes to customize the images displayed for navigation. All these attributes are mandetory attributes.
    • imgFirst - Custom image to be displayed for navigate to first page action.
    • imgPrevious - Custom image to be displayed for navigate to previous page action.
    • imgNext - Custom image to be displayed for navigate to next page action.
    • imgLast - Custom image to be displayed for navigate to last page action.

  2. gridsorter - This control is responsible for providing the sort support. The most important and required attributes for this control are:
    • sortColumn - The name of the column to be used while constructing ORDER BY clause.
    • sortAscending - The boolean value indicating whether to sort in ascending order or descending order.

    Apart from above two attributes this control has following two optional attributes to customize the images that appear in the column header to indicate the current sort order. If not specified the control assumes that ImgAsc.gif and ImgDesc.gif are present in the images folder.

    • imageAscending - Image to be displayed in header of the associated column when the data issorted in ascending order.
    • imageDescending - Image to be displayed in header of the associated column when the data is sorted in descending order.

  3. textColumn - This control is responsible for rendering the text column. The control has following special attributes to control the apperance of the rendered text.
    • maxLength - Controls the number of character to be outputted.

  4. dateColumn - This control is responsible for rendering the date time values. The control has following special attributes to control the apperance of the rendered text.
    • dataFormat - The format string as defined in java.text.DateFormat

  5. numberColumn - This control is responsible for rendering the numeric values. The control has following special attributes to control the apperance of the rendered text.
    • dataFormat - The format string as defined in java.text.DecimalFormat

  6. anchorColumn - This control is responsible for rendering the hyperlinks. This control also supports value substitution as explained in previous section. The control has following special attributes to control the apperance and behavior of the hyperlink.
    • linkText - A fixed string to be used to render the hyperlink. Alternatively one can also specify the column value to be used using dataField attribute
    • linkUrl - The url to be invoked when this link is clicked. This can also be a javascript function.
    • target - The name of the window or frame in which the referenced url is to be opened.

  7. imageColumn - This control is responsible for rendering the hyperlinked image. This control also supports value substitution as explained in previous section. The control has following special attributes to control the apperance and behavior of the hyperlink.
    • imageSrc - The image to be displayed.
    • imageWidth - The width of the image in pixels.
    • imageHeight - The height of the image in pixels.
    • imageBorder - The width of the image border in pixels.
    • alterText - The tooltip text to be displayed.
    • linkUrl - The url to be invoked when this link is clicked. This can also be a javascript function.
    • target - The name of the window or frame in which the referenced url is to be opened.

  8. rownumColumn - This control is responsible for numbering the rows displayed in the gird.

  9. decodeColumn - This control is responsible for decoding the column values and display the decoded text. The control has following special attributes to control the decoding.
    • decodeValues - A string containing values to be decoded seperated by the delimeter specified using valueSeperator attribute.
    • displayValues - A string containing values to be displayed seperated by the delimeter specified using valueSeperator attribute.
    • valueSeperator - The value delimeter.

DBGrid Control Container

The DBGrid control it self has following special properties.

  1. dataSource - Allows one to specify the java.sql.Connection object to be used to fetch the values from database or a java.util.List.
  2. dataMember - The SQL to be used to retrieve the required data. The SQL should not contain the ORDER BY clause. If you are specifying java.util.List for dataSource then this can be left blank.
  3. pageSize - The number of rows to be displayed in a page.
  4. currentPage - The page number to be displayed.

Using the code

following code snippet shows the DBGrid control usage. The same source can also found in the demo application.

<%@ taglib uri="/WEB-INF/tags/datagrid.tld" prefix="grd" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.SQLException" %>
<%@ page import="com.freeware.gridtag.*" %> 
<%
int intCurr = 1;
int intSortOrd = 0;
String strTmp = null;
String strSQL = null;
String strSortCol = null;
String strSortOrd = "ASC";
boolean blnSortAsc = true; 
strSQL = "SELECT CLICORPORATION, CLICLIENT, CLIDESCRIPTION, " +
         "CLIENABLED, CLIUPDSTAMP FROM CLIENTMASTER "; 
Connection objCnn    = null;
Class      objDrvCls = null;
objDrvCls = Class.forName("oracle.jdbc.driver.OracleDriver");
objCnn = DriverManager.getConnection("jdbc:oracle:thin:@Host:port:sid", 
                                     "cashincpri", "cashincpri");
if (objDrvCls != null) objDrvCls = null;
strTmp = request.getParameter("txtCurr");
try
{
  if (strTmp != null)
  intCurr = Integer.parseInt(strTmp);
}
catch (NumberFormatException NFEx)
{
}
strSortCol = request.getParameter("txtSortCol");
strSortOrd = request.getParameter("txtSortAsc");
if (strSortCol == null) strSortCol = "CLICLIENT";
if (strSortOrd == null) strSortOrd = "ASC";
blnSortAsc = (strSortOrd.equals("ASC"));
%>
<html>
<head>
<title>Grid Tag Demonstration</title>
<link REL="StyleSheet" HREF="css/GridStyle.css">
<script LANGUAGE="javascript">
function doNavigate(pstrWhere, pintTot)
{
  var strTmp;
  var intPg; 
  strTmp = document.frmMain.txtCurr.value;
  intPg = parseInt(strTmp);
  if (isNaN(intPg)) intPg = 1; 
  if ((pstrWhere == 'F' || pstrWhere == 'P') && intPg == 1)
  {
    alert("You are already viewing first page!");
    return;
  }
  else if ((pstrWhere == 'N' || pstrWhere == 'L') && intPg == pintTot)
  {
    alert("You are already viewing last page!");
    return;
  }
  if (pstrWhere == 'F')
    intPg = 1;
  else if (pstrWhere == 'P')
    intPg = intPg - 1;
  else if (pstrWhere == 'N')
    intPg = intPg + 1;
  else if (pstrWhere == 'L')
    intPg = pintTot; 
  if (intPg < 1) intPg = 1;
  if (intPg > pintTot) intPg = pintTot;
  document.frmMain.txtCurr.value = intPg;
  document.frmMain.submit();
}
function doSort(pstrFld, pstrOrd)
{
  document.frmMain.txtSortCol.value = pstrFld;
  document.frmMain.txtSortAsc.value = pstrOrd;
  document.frmMain.submit();
}
</script>
</head>
<body>
<h2>Grid Example</h2>
<form NAME="frmMain" METHOD="post">
<grd:dbgrid id="tblStat" name="tblStat" width="100" pageSize="10" 
    currentPage="<%=intCurr%>" border="0" cellSpacing="1" cellPadding="2" 
    dataMember="<%=strSQL%>" dataSource="<%=objCnn%>" cssClass="gridTable">
 <grd:gridpager imgFirst="images/First.gif" imgPrevious="images/Previous.gif" 
      imgNext="images/Next.gif" imgLast="images/Last.gif"/>
 <grd:gridsorter sortColumn="<%=strSortCol%>" sortAscending="<%=blnSortAsc%>"/>
 <grd:rownumcolumn headerText="#" width="5" HAlign="right"/>
 <grd:imagecolumn headerText="" width="5" HAlign="center" 
      imageSrc="images/Edit.gif" 
      linkUrl="javascript:doEdit('{CLICORPORATION}', '{CLICLIENT}')" 
      imageBorder="0" imageWidth="16" imageHeight="16" 
      alterText="Click to edit"/>
 <grd:textcolumn dataField="CLICLIENT" headerText="Client" 
      width="10" sortable="true"/>
 <grd:textcolumn dataField="CLIDESCRIPTION" headerText="Description" 
      width="50" sortable="true"/>
 <grd:decodecolumn dataField="CLIENABLED" headerText="Enabled" width="10" 
      decodeValues="Y,N" displayValues="Yes,No" valueSeperator=","/>
 <grd:datecolumn dataField="CLIUPDSTAMP" headerText="Last Updated" 
      dataFormat="dd/MM/yyyy HH:mm:ss" width="20"/>
</grd:dbgrid>
<input TYPE="hidden" NAME="txtCurr" VALUE="<%=intCurr%>">
<input TYPE="hidden" NAME="txtSortCol" VALUE="<%=strSortCol%>">
<input TYPE="hidden" NAME="txtSortAsc" VALUE="<%=strSortOrd%>">
</form>
</body>
</html>
<%
try
{
    if (objCnn != null)
        objCnn.close();
}
catch (SQLException SQLExIgnore)
{
}
if (objCnn != null) objCnn = null;
%>

The attached demo zip file also contains the ddl and dml which you can directly use to create the necessary table and populate the test data. I have tested this control using oracle database and the jdbc thin driver. For other databases you may have to change the dml.

References

The links which helped me a lot in designing this control library,

History

  • July 27, 2004 - Initial release.
  • May 12, 2005 - Added support for List. DBGrid can now render data supplied as object list. Changed names of sourceSQL to dataMember and connection to dataSource. Updated sample application to demonstrate the same.
  • June 03, 2005 - Updated the sample code in article to reflect the changes made in last release.
  • January 10, 2006 - Added support for ResultSet and RowSet. Added new sample RawJDBCGrid.jsp page to demonstrate this. While supplying these types of object as dataSource care must be taken to make this ResultSet SCROLLABLE (ie. ResultSet.TYPE_SCROLL_INSENSITIVE).
  • April 07 2006 - Fixed the bug in page navigation. Credit goes to Member No. 2833981 for pointing out this bug.
  • July 22, 2006 - Small bug fix to allow multiple dbgrids on single page. All credit goes to to Dave Lilley for pointing out this bug as well as suggesting the solution.

License

This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)

About the Author

Prasad Khandekar
Software Developer (Senior) Freelancer
India India
I am a software professional with over 20 years of commercial business applications design and development experience.
 
My programming experience includes Java, Spring, .NET, Classic VB & ASP, Scripting, Power Builder, PHP, Magic & far far ago FoxPro, C, Assembly and COBOL.
 
From last 11 years I am mostly working with Java Technology. I am currently available to take up new assignments.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralRe: AnchorColumn and dataField [modified]memberramyaintergy19-May-09 14:09 
Hi There,
 
I ran into the same issue. You are doing it right but the "linktext" property and imageSrc property do not resolve data field value they only accept plain text. I have fixed the code and built a new jar to resolve this issue please provide your email address I can send the jar if required.
 
Thanks for Mr.Prasad for a wonderful grid control and source code. Helped me to customize easily. Hope you don't mind me providing customized jar.
 
Thanks,
Ramya
 
modified on Tuesday, May 19, 2009 8:15 PM

GeneralRe: AnchorColumn and dataFieldmemberSubhashK26-Jun-09 1:19 
I have same problem please send me the jar file on this email id :
skatakdhond@gmail.com
GeneralRe: AnchorColumn and dataFieldmembermanishipra25-May-10 19:14 
I have the same problem ,I am not able to bind Anchor text with datafield
 
please send me the solution
 

Thanks
Manish
GeneralUpdating/Getting Handle to the Fieldsmemberbmeksava10-May-09 21:13 
I am trying to figure out how i can get a handle to the fields. For example, I want to do update the data. How would I be able to edit the data and then do updates against them.
 
Thanks,
 
Boon
QuestionAny licensing issues ?memberprabhjit singh deol27-Apr-09 18:54 
Hi Prasad,
 
The tool looks great. Just wanted to know if it would be OK to use this code and the associated jar files in commercial applications? Are there any legal/licensing/GPL issues ? Is there any kind of licensing at all associated with this?
 
Regards
PSD
AnswerRe: Any licensing issues ?memberPrasad Khandekar6-Jun-09 23:28 
Hello Prabhjit ,
 
You can use the code in commercial applications without any problem. The code is totally free. The DBGrid code does not fall under GPL.
 
Regards,
 
Prasad P. Khandekar
Knowledge exists, man only discovers it.

Questioncan u tell me how to use it ??memberbassoom19-Mar-09 2:51 
can you tell me how to use it ??
what are the configurations must be done at first??
GeneralCheckBox Column in JSP DataGrid.memberlucianodev43-Feb-09 14:27 
have to implement CheckBox Column in JSP DataGrid?
 
have new version ?
QuestionHow does the doEdit function work?memberrajesh_css6-Jan-09 15:34 
can anyone help me ,how the doEdit function works and what are the parameters passed in.......
 
Regards
Raj
GeneralDbGridmemberMember 415987126-Aug-08 0:04 
As I am new for java developement and read this code, Finally I try to implement this code and got success also.
 
Only one problem I am facing that the alterText on Image Column is not working.
 
<grd:imagecolumn headerText="" width="5" HAlign="center" imageSrc="images/Edit.gif"
linkUrl="javascript:doEdit('{CLICORPORATION}', '{CLICLIENT}')" imageBorder="0"
imageWidth="16" imageHeight="16" alterText="Click to edit"></grd:imagecolumn>
 

Can some one help me why the tool tips is not showing...
 
Regards
Smile | :)
GeneralCheckBox Column In JSP DataGridmemberamnahi30-Jun-08 3:05 
Hi,
 
I have to implement CheckBox Column in JSP DataGrid.
Anyone knowing solution please do reply.
 
Thanks in advance.
 
Aman
QuestionHow can get Pagination with Numbers(1 2 3 4 5 6 7 8 9 10 Next)memberashokadcrl12-Jun-08 1:36 
Hi All,
 
How can I get the Pagination with Numbers(1 2 3 4 5 6 7 8 9 10 Next) instead of First,Prvious,Next,Last.
 
Can anyone help to get the pagination in above format.
 
Thanks
Generali am not able to use this grid in my applicationmemberrenjithpaul18-Apr-08 0:08 
sir,
i am nw to jsp and java .I am in very much need of a data grid like this, but i cant implement it in my application.. sir please give me step by step implementation of this grid.. i had reffered to the previous post but im getting some error when i did it like that..
org.apache.jasper.JasperException: File "/WEB-INF/datagrid.tld" not found
 
plzz help me...
GeneralRe: i am not able to use this grid in my applicationmemberniket_shah8330-Apr-09 0:23 
This tld File is in config folder
so please put this config folders file in to your web-inf folder
its work then
QuestionNumer field not showingmemberBisweswar26-Dec-07 19:40 
I had put the codes as per need, and it works fine.
But Unfortunately the fields of type Number/Int not being shown in grid.
 
Please fix the error and give the solution immeditely.
 
Thanking you,
Bisweswar
AnswerRe: Numer field not showingmemberJMVillaG3-Apr-08 9:50 
Number Field are showing correctly. Poke tongue | ;-P
But you must include the dataFormat property to the column.
ex.
To know about format, visit :
http://java.sun.com/j2se/1.4.2/docs/api/java/text/DecimalFormat.html

QuestionCan I insert and update values into the gridmemberMember 31100629-Dec-07 21:08 
Hi,
 
Is it possible to enter values and update them in the grid? If so can anyone give me a sample of the code
 
Regards
Anil
Questionhow to use listmembersumouser13-Nov-07 23:00 
Dear sir,
 
Grid for java is really a great job and it will help us (the developers) a lot.
I want to use it in my college project where i am presenting information in form of table. the scenario is that I am getting value from data base using bean method which returns List. the List contains Array of string.
Now I want to use your grid to show the data in tabular format. but i am facing problem. in fact i am not how to use the list. When i go through the queries related to it i found a reply by you in this regard that is
 
The request attribute named 'DATALIST' stores a reference to pojo List.
In case of pojos the attribute 'dataField' of any grid column holds the name of the getter method excluding the prefix 'get'.
e.g. If you hava a getter method named 'getDescription' coded for your pojo then specify value 'Description' in 'dataField' attribute of the grid column.
 
In this reply you have metioned pojo List. Can you help me to understand pojo list. what it is or how can i create a pojo list. if you provie any link in this regard it will help a lot.
 
Plz help me.
 
waiting for your valuable information
 

Thanks
 
sumouser
 
sumouser
Generalgenerating rows using JSPmemberlamarjones7-Sep-07 4:06 
I have tried using jsp code to generate the
GeneralRe: generating rows using JSPmemberiren1-Apr-08 6:19 
Hai friend send me generating rows using JSP code plz..
QuestionIs Multiple Grid Code available?membernyy_28-Aug-07 5:27 
Hello - Is Dave Lilley's code for displaying multiple grids on a page available? It wasn't in the download project or demo. I figured I would ask before I reinvent the wheel and do it myself. Thanks!
GeneralPrinting grid data..membertwinvaibhav6-Aug-07 0:32 
Hey
hi
 
i tried to print the grid data...but no success
pls is ther any solution???

 
There's never a Wronge Time To Do The Right Thing !!

GeneralRe: Printing grid data..membervishaldsh8-Dec-09 21:25 
What error you are getting
GeneralRe: Printing grid data..membertwinvaibhav9-Dec-09 1:05 
vishaldsh,
 
Thanks for your reply..although I dont remember what was the error as I had posted this problem way back in 2007... Big Grin | :-D
 
There's never a Wronge Time To Do The Right Thing !!

Questionsecurity alert popup.membertechmalli25-Jul-07 7:39 
Hi, when i am scrolling the mouse in the data grid, i am getting a security alert popup. This is in https env. works fine in http env. Any issues in the css?
 
can anyone help on this?

GeneralGive and take, I talk about my edit, you tell me your thoughts on printing....memberlamarjones25-Jul-07 3:48 

 
you can see there are things in the 'doedit' fields, these are strictly to tell me what row number and column number I am on. by clicking on any of the fields it will send that particular string back to the rendering class. How?
 
These tag library variables work as setters and getters, google what that means. But basically, add a variable to the .tld file, and then you got to make a setter and getter function wherever the rendering is going on, I put it in DBGrid.java.
 
So I added
 

editAction
true
true
java.lang.String


editBoolean
true
true
java.lang.Boolean

 
to the tld file, and then
 
/**
* Sets editAction.
*
*/
public String getEditAction()
{
return this.mstrEditAction;
}
/**
* Sets editAction.
*
*/
public boolean getEditBoolean()
{
return this.mstrEditBoolean;
}
 
along witht he get functions as well. This is passed in by stating in the call to the dbgrid tag library when trying to render it.
 

 

Now, depending on what type of value is being retrieved, you basically trap these statements in either the text column, image column, number column classes and so forth. Here is an example of what I did on my text columns.
 
private void setFlags() throws JspException
{
isRowEdit=false;
isCellEdit=false;
isEditAction=false;
editRow=-1;
editCol=-1;

try {
 
objTmp = (DBGrid) getParent();
rowNum=objTmp.rowNum;
colNum=objTmp.colNum;
editAction=objTmp.getEditAction();
if (editAction.indexOf("rowNum=")>-1){
isEditAction=true;
isRowEdit=true;
editRow=Integer.parseInt(editAction.substring(7));
}

if (editAction.indexOf("mouseClick=")>-1){
isEditAction=true;
isCellEdit=true;
editRow=Integer.parseInt(editAction.substring(11,editAction.indexOf("|")));
editCol=Integer.parseInt(editAction.substring(editAction.indexOf("|")+1));
}
} catch (Exception e) {
throw new JspException(e.getMessage());
}
}
 

 
That is actually called early in render detail, this snippet is done later on.
 
try
{
objBuf = new StringBuffer();
objBuf.append(" 0)
objBuf.append(" WIDTH=\"" + this.mintWidth + "%\"");
if (this.mintHeight > 0)
objBuf.append(" HEIGHT=\"" + this.mintHeight + "\"");
if (this.mstrCssClass != null)
objBuf.append(" CLASS=\"" + this.mstrCssClass + "\"");
else
objBuf.append(" CLASS=\"gridColumn\"");
if (this.mstrHAlign != null)
objBuf.append(" ALIGN=\"" + this.mstrHAlign.toLowerCase() + "\"");
if (this.mstrVAlign != null)
objBuf.append(" VALIGN=\"" + this.mstrVAlign.toLowerCase() + "\"");
 
if (this.mstrBgColor != null)
objBuf.append(" BGCOLOR=\"" + this.mstrBgColor + "\"");
if (this.mstrForeColor != null)
objBuf.append(" COLOR=\"" + this.mstrForeColor + "\"");
 

objBuf.append(">");
if (isEditAction){
if (rowNum==editRow){
if ((editCol==colNum)){
//block for single cell to be edited
strVal = formatField(pobjValue, this.mstrDataFormat);
if (strVal != null && this.mintMaxLength > 0)
if (strVal.length() > this.mintMaxLength)
strVal = strVal.substring(0, this.mintMaxLength) + "...";


objBuf.append("<input type=\"text\" name=\"field"+colNum+"\" value='"+strVal+"'>");
objBuf.append("</input>
");
} else if (editCol==-1) {
//block for whole row to be edited
strVal = formatField(pobjValue, this.mstrDataFormat);
if (strVal != null && this.mintMaxLength > 0)
if (strVal.length() > this.mintMaxLength)
strVal = strVal.substring(0, this.mintMaxLength) + "...";


objBuf.append("<input type=\"text\" name=\"field"+colNum+"\" value='"+strVal+"'>");
objBuf.append("</input>");
} else
{
//non edited rows when edit requested
strVal = formatField(pobjValue, this.mstrDataFormat);
if (strVal != null && this.mintMaxLength > 0)
if (strVal.length() > this.mintMaxLength)
strVal = strVal.substring(0, this.mintMaxLength) + "...";
objBuf.append(strVal);
}
} else {
objBuf.append("");
strVal = formatField(pobjValue, this.mstrDataFormat);
if (strVal != null && this.mintMaxLength > 0)
if (strVal.length() > this.mintMaxLength)
strVal = strVal.substring(0, this.mintMaxLength) + "...";
objBuf.append(strVal);
objBuf.append("
");
}

}else {

objBuf.append("");
strVal = formatField(pobjValue, this.mstrDataFormat);
if (strVal != null && this.mintMaxLength > 0)
if (strVal.length() > this.mintMaxLength)
strVal = strVal.substring(0, this.mintMaxLength) + "...";
objBuf.append(strVal);
objBuf.append("
");
}
 
// Write created HTML to output stream.
this.pageContext.getOut().print(objBuf.toString());
}
 

Ok, that should suffice for now. Figure out the rest (notice that I am getting a jsp datepopup to come out for the date columns?) as I am not fielding questions on this.
 
But someone tell me how to print this in specfic formats!!
 


 
lamarjones@nc.rr.com
Ok, what I want to do is to print this data sheet, how would you recommend I do that?
 
In exchange, I'll talk about my editing procedure. I have done a couple of things, none great but pretty cool.
 
I got to a point where my rows look like this.
 
<img SRC="images/Edit.gif" WIDTH=16 HEIGHT=16 BORDER=0 ALTER="null">06/07/2000 00:0001/01/1960 01:2201/01/1960 01:42T - 173,973.36 Sq. Ft. Charles Harris 3rd - 2200 - 0600
Generala request from johnson josephadminSean Ewington23-Jul-07 4:18 
"i am not able to configure this demo project...actually i changed database from oracle to mysql...and i put this all application into my context path...so which URL i have to type in my address bar for accessing this application...let me know your suggections... context path "
- johnson joseph
GeneralLicense - supported J2EE levelmemberjfqjfq9-Jul-07 23:36 
Good morning,
 
Two newby questions. Which is the license of that component ? Is it allowed to re use the component in a commecial application, by reproducing the content of the license ?
 
Does the tag lib work with Tomcat 4.1.x (J2EE 1.3 level). Are specific JSP 2.0 features used ?
 
Regards
GeneralEditable Gridmemberfuzzysoft14-Jul-07 22:31 
Prasad,
 
Can this grid work like excel Sheet? Editable cells with navigation thru
arrow keys?
 
Thanks & Regards
 

 
Anjali
QuestionExample of doEdit()?memberKevin Ternes3-Jul-07 5:24 
It would be very helpful if someone could post an example of the doEdit() javascript function.
QuestionHow to implement edit functionmemberAP_java2-Jun-07 2:44 
Hi i want to know how to implement edit functin in this tld.
 
It's very urgent.
thanks in advance.
 
Thaks
 
AP_java
QuestionError in using tag library uri='/WEB-INF/datagrid.tld'memberNirmal tony1-Jun-07 2:30 
Dear Sir,
 

I am getting some problem as follows
 
/grid.jsp(15): Error in using tag library uri='/WEB-INF/datagrid.tld' prefix='grd': type mismatch for property 'border', for Tag class 'com.freeware.gridtag.DBGrid': tld says java.lang.Integer, implementation type is int
probably occurred due to an error in /grid.jsp line 15:
<%@ taglib uri="/WEB-INF/datagrid.tld" prefix="grd"%>
 
I am using jdk 1.4.2_06 with myecllipse 5.1 integrate weblogic 8.1
pls solve it....
 

 
Thanks with regs,
 
Rodricks
QuestionDatagrid using Resultsetmemberyogesh_prajapati30-May-07 3:11 
How can i use resultset instead of list as a value of dataSource property of grd:dbgrid .
 

The problem is that, i have class which returns resultset instead of list. I want to use this resultset to fill the data in datagrid...

Plz send me solution as soon as possible..
thanx in advance..
my email id is givelove_getlove009@yahoo.co.in
 
Rose | [Rose] Rose | [Rose] Rose | [Rose] Rose | [Rose] Rose | [Rose] Rose | [Rose] Rose | [Rose] Rose | [Rose] Rose | [Rose] Rose | [Rose] Rose | [Rose]
 
Yogesh Prajapati,
Java Developer,
Ahmedabad...
GeneralNewb taglib conceptual error: Missing tagclass for tag "dbgrid"membergeoffalot28-May-07 9:03 
Newb Taglib conceptual error:
"Missing tagclass for tag 'dbgrid'"
 
I am attempting to integrate a datagrid taglib into a small test
application.
 
The Datagrid lives here:
http://www.codeproject.com/useritems/DBGrid.asp?df=100&forumid=82119&fr=26
 
My .jsp starts with the following:
 
< %@ taglib uri="/WEB-INF/tags/datagrid.tld" prefix="grd" % >
 
< %@ page import="java.sql.Connection" % >
< %@ page import="java.sql.DriverManager" % >
< %@ page import="java.sql.SQLException" % >
< %@ page import="com.freeware.gridtag.*" % >
 

The taglib section from my web.xml looks like this:
 
< taglib >
< taglib-uri >/tags/datagrid.tld< /taglib-uri >
< taglib-location >/WEB-INF/tags/datagrid.tld< /taglib-location >
< /taglib >
 
(The file datagrid.tld definitely lives under /WEB-INF/tags)
 

My datagrid taglib descriptor starts like this:
 
< taglib >
< tlib-version >1.0< /tlib-version >
< jsp-version >1.2< /jsp-version >
< short-name >DBGrid< /short-name >
< display-name >DBGrid< /display-name >
< small-icon >images/dbGridS.gif< /small-icon >
< large-icon >images/dbGridM.gif< /large-icon >
< description >JSP Data Grid Tag Library< /description >
 
< tag >
< name >dbgrid< /name >
< tag-class >com.freeware.gridtag.DBGrid< /tag-class >
 

The error I am receiving on the jsp is:
dg.jsp Line 1: Missing tagclass for tag "dbgrid"
 
In the .jsp, I can import all the classes in datagrid.tld with "@ page
import" directives, but something I am doing wrong is making it
impossible to for the application to "see" the tagclasses via a
taglib.
 
If it matters - I am running this on Blazix.
 
Any help greatly appreciated.
 
Geoff

GeneralRe: Newb taglib conceptual error: Missing tagclass for tag "dbgrid"memberPrasad Khandekar31-May-07 5:07 
Hello Geoff,
 
Have you looked at the sample project? Also check whether Blazix is compliant with JSP 2.0 spec.
 
Regards,
Prasad P. Khandekar
 
Prasad P. Khandekar
Knowledge exists, man only discovers it.

Questionnumbercolumn: number not showmemberphoebeching24-May-07 14:45 
Hi, good day,
I got a code shown below to display out number to datagrid but it seems not working.

 
Can someone help? Thanks in advanced.
GeneralRe: numbercolumn: number not showmemberkidd.sadam4-Apr-08 9:31 
I had a same problem.. You must write 'dataFormat=""' in your code..
Example: dataFormat="">
 
if missing 'dataFormat=""' that doesn't work...
Questionhow to use the example (DemoGrid) given above with Tomcat 4??memberMayank_T17-May-07 20:15 
i am not able to run the example, DemoGrid, please help. I trying it with Tmcat 4, is Tocat 4 is a problem??
 
Thanks,
Mayank

QuestionNew Formatter class?membernyy_225-Apr-07 9:49 
Has anyone given thought to coding a "FormattedObject" class (similar to DateColumn, I guess) for things like phone numbers, social security nums, and other commonly formatted values? I figured I would ask before I re-invent the wheel and code it from scratch. Thanks!
 
nyy2
QuestionEmpty data fields in the grid?membernyy_223-Apr-07 10:21 
Hello - I am trying to implement the JSP on this page. My attribute dataSource of the grid tag is a Connection (SQL executed in the JSP). My problem is the grid data fields are null...however, I have the correct sql total count. It seems as though I am able to page & sort fine but I can't get my data to display in the grid. Has anyone had this problem??
Thanks!
 
nyy2
AnswerRe: Empty data fields in the grid?membervishaldsh8-Dec-09 21:26 
check the field name
Questionhow to use this source..as i am new to j2eememberkushdev23-Apr-07 0:32 
how to include the tag lib..
how to use this source code in my project..
Will u plz give me step by step detail..
Thanks in Advance
GeneralDisplay Multipal Grid [modified]memberPallavi Jagtap11-Apr-07 20:24 
Hi,
I want to display multipal grid in one page.
Please help me.
 
Thanks
Pallavi
 

-- modified at 2:46 Thursday 12th April, 2007Blush | :O Rose | [Rose]
GeneralRe: using beanmemberm_metwally11-Apr-07 0:15 
it works but after changing the "firstName" dataField to "FirstName" & also lastName
i don't know why thought i m using userName as it s in the bean class parameter i think it'll bother me coz I'll use the grid in a code generation template.
& they r exactly the same in the bean
& also why doSort doesn't work
& how can i make doEdit work
but anyway thanks a lot for this tag lib it easy to use & no license it s really good
thanks in advance
Generalusing beanmemberm_metwally10-Apr-07 23:27 
i using the grid list with an arraylist fill of beans but the grid only shows the first parameter in the bean class (bean class exactly like the Client class in ur demo except it called UserBean )
User bean had (username , firstName ,lastname) the grid shows only the userName
plz help

Questionwarning while starting TomCatmembervenkprabhu27-Mar-07 21:19 
I got the following warning while starting the Tomcat server, so that the error what I have posted earlier is coming. Please help me to solve it.
 
VenkPrabhu
---------------------------
WARNING: A docBase D:\Tomcat5\webapps\GridDemo inside the host appBase has been
specified, and will be ignored
log4j:WARN No appenders could be found for logger (org.apache.catalina.startup.T
ldConfig).
log4j:WARN Please initialize the log4j system properly.
Mar 28, 2007 12:45:47 PM org.apache.coyote.http11.Http11BaseProtocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Mar 28, 2007 12:45:47 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Mar 28, 2007 12:45:47 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/70 config=null
Mar 28, 2007 12:45:47 PM org.apache.catalina.storeconfig.StoreLoader load
INFO: Find registry server-registry.xml at classpath resource
Mar 28, 2007 12:45:47 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2563 ms
 


QuestionERROR - Cannot create resource instancemembervenkprabhu27-Mar-07 20:27 
While deploying the GridDemo application, I got the HTTP Status 500 - Exception report.
 
please help to solve it.
 
Thanks in advance
Venkprabhu
---------------------------------------
type Exception report
 
message
 
description The server encountered an internal error () that prevented it from fulfilling this request.
 
exception
 
org.apache.jasper.JasperException: Cannot create resource instance
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1056)
org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:994)
org.apache.struts.action.RequestProcessor.processForward(RequestProcessor.java:553)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:211)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 

root cause
 
javax.servlet.ServletException: Cannot create resource instance
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:843)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:776)
org.apache.jsp.WEB_002dINF.pages.JDBCGrid_jsp._jspService(JDBCGrid_jsp.java:318)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1056)
org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:994)
org.apache.struts.action.RequestProcessor.processForward(RequestProcessor.java:553)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:211)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 


Generalmutiple gridsmemberMember #394807622-Mar-07 0:45 
can i use a grid with a grid -- for somrthing like a table tree view
QuestionSybase ODBC config -- GridDemo.xmlmemberY2KGanesan14-Mar-07 23:04 




factory
org.objectweb.jndi.DataSourceFactory


password
janus123


url
jdbc:sybase:Tds:10.192.103.42:9000:janus


driverClassName
com.sybase.jdbc3.jdbc.SybXADataSource


user
janusop



 
Is it correct configuration to SYBASE am getting following error msg.
 
javax.servlet.ServletException: Cannot create JDBC driver of class '' for connect URL 'null'
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
org.apache.jsp.JDBCGrid_jsp._jspService(org.apache.jsp.JDBCGrid_jsp:300)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 

root cause
 
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:780)
org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
org.apache.jsp.JDBCGrid_jsp._jspService(org.apache.jsp.JDBCGrid_jsp:111)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.12 logs.
 
Thank you so much well in advance for your help.
 
Kind regards,
Pon
 
Hi am newly joined in this forum. This forum is very good for developers.

AnswerRe: Sybase ODBC config -- GridDemo.xmlmemberPrasad Khandekar15-Mar-07 6:23 
Hello,
 
I have checked the GrdDemo.xml which you have posted in your message. Apperantly you forgot to change the full class name in Type attribute in following line:

<Resource name="jdbc/DBGrid" type="oracle.jdbc.pool.OracleConnectionCacheImpl" scope="Sharable"/>

 
For sybase database you should be using their impl. I think if you are using j_Connect 6.05 version of sybase driver the above line would read as:

<Resource name="jdbc/DBGrid" type="com.sybase.jdbc3.jdbc.SybConnectionPoolDataSource" scope="Sharable"/>

 
Hope this solves your problem.
 
Regards,
 
Prasad P. Khandekar
Knowledge exists, man only discovers it.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130617.1 | Last Updated 21 Jul 2006
Article Copyright 2004 by Prasad Khandekar
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid