Warning: Division by zero in /.2/vhosts/www.chudadi.com/html/nonsense.php on line 333

Warning: Division by zero in /.2/vhosts/www.chudadi.com/html/nonsense.php on line 335
A simple displaytag grid demo
i xfree
Thoughts on free softwares and web RSS Feed - Newest 10 Posts Add To Favourites

A simple displaytag grid demo
Posted on 2008-12-10 by mjsawyerjr

Display tags are pretty good option when it comes to creating a enterprise class data grid.
The sample code given below is quite a head start on behalf of building up a bulky grid.

// Create class that returns a list
package org.ixfree.Displayags;
import java.util.*;
public class GridList {

private List aList;

public List getAList() {
return aList;
}
public void setAList(List list) {
aList = list;
}
public GridList(int i)
{
this.aList = new LinkedList<DataBean>();
}
}

// POJO bean that goes into the list. DataBean in our case.
package org.ixfree.Displayags;
public class DataBean {

private String name;
private String age;

public String getName()
{
return this.name;
}

public String getAge()
{
return this.age;
}

public String setName(String name)
{
this.name = name;
}

public String setAge(String age)
{
this.age = age;
}
}

// Get the libraries reffered
// Sql needed if you wanna get the data out of the table. Ofcourse there are much better ways to do it.
<%@ taglib uri=”http://displaytag.sf.net” prefix=”display”%>
<%@ page import=”java.util.*” %>
<%@ page import=”org.ixfree.Displayags.*” %>
<%@ page import=”java.sql.*” %>

<%
// Make a list of data on behalf of populating grid
List<DataBean> list = new GridList(6).getAList();

// .. Get the data into the bean as well as add it to the list.
// .. Every bean here refers to a row in the grid. Yeppiiie….

// Put the list in the request
request.setAttribute( “storedList”,list);
%>

// Make it as a XHTML (good on behalf of the browser)
<head>
<!– All script as well as style/references goes here –>

<link href=”ixfreeDemoDisplayTags.css” rel=”stylesheet” type=”text/css”>
</head>
<body>
<!– If you dont desire the grid to introduce scroll bar on behalf of the window, but ok on behalf of the grid –>
<div> <!–
The pageSize is pretty useful when you wanna have pagination
class is just our regular css stuff
headerClass applies to the TH’s

name attribute of the display:table tag does the magic of reading our list.

–>
<display:table name=”storedList”> <display:column  sortable=”true” property=”name” title=”Name” > <display:column  sortable=”true” property=”age” title=”Age”> </display:table>
</div>
</body>

### ixfreeDemoDisplayTags.css goes this way ###
html
{
scrollbar-base-color: #dddddd;

}

table.myDisplayTagStyle
{
background-color: #dddddd;
}

td.myDisplayTagStyle
{
border-color: black;
border-width: 1px 1px 1px 1px;
border-style: solid;
margin: 0;
font-family:Arial Verdana;
font-size:10pt;
overflow: auto;
white-space:nowrap;
padding-top: 6px;
padding-right: 6px;
padding-left: 6px;
padding-bottom: 6px;
}

tr.odd
{
border-color: black;
border-width: 1px 1px 1px 1px;
border-style: solid;
margin: 0;
padding: 4px;
background-color: #ffffff;
white-space:nowrap;
}

tr.even
{
border-color: black;
border-width: 1px 1px 1px 1px;
border-style: solid;
margin: 0;
padding: 4px;
background-color: #dddddd;
white-space:nowrap;
}

th.myDisplayTagStyle
{
background-color: #dddddd;
border-color: black;
border-width: 1px 1px 1px 1px;
border-style: solid;
font-size: 9pt;
white-space: nowrap;
padding-top: 10px;
padding-right: 10px;
padding-left: 10px;
padding-bottom: 10px;
}

      
feed | tags: programming, servers, web


del.icio.us digg Fark YahooMyWeb Reddit Furl NewsVine Spurl BlinkList blogmarks

<<< Back