May 4, 2008

Dynamic tables with JMesa

JMesa is a very useful open source project.It is a dynamic HTML table that allows you to edit, filter, sort, paginate and export your data. By my opinion it is a really cool and useful tool for development a java web applications. Here is a simple and fast tutorial and example.
What do you need to run this tutorial?
1. JDK, JMesa requires 1.5 or above, I recommend 1.6
2. IDE - I'll use my favorite eclipse
3. JMesa latest
4. JQuery, JMesa requirement, prefer the latest version
5. I'll use Struts

OK, now what to do. Extract the jmesa archive and create new web project. Put jmesa.jar on your WEB-INF/lib directory. Put the JavaScript, CSS and image files in the corresponding folders. For me that would be /scripts, /styles and /images. For the data bean I'll use simple class Framework

public class Framework {
String name;
String url;
String license;
Boolean like;

public Framework(String name, String url, String license, Boolean like) { = name;
this.url = url;
this.license = license; = like;
public String getName() {
return name;
public String getUrl() {
return url;
public void setName(String name) { = name;
public void setUrl(String url) {
this.url = url;
public String getLicense() {
return license;
public Boolean getLike() {
return like;
public void setLicense(String license) {
this.license = license;
public void setLike(Boolean like) { = like;

Our framework action or servlet must set the data collection, in our case it will do something like this:

Framework jquery = new Framework("jQuery", "", "MIT & GPL", true);
Framework mootools = new Framework("Mootools", "", "MIT License", true);
Framework gwt = new Framework("Google Web Toolkit", "", "Apache License", false);
Framework dojo = new Framework("Dojo", "", "BSD & AFL", false);
Framework prototype = new Framework("Prototype", "", "MIT License", false);

ArrayList frameworks = new ArrayList();

request.setAttribute("frameworks", frameworks);

And our framework.jsp file:

And thats it. Our jmesa table is ready to be shown on public. Simple, easy and fun.


Radhika Ganesan said...

I am trying to use JMesa as i need to make a POC for the same, if it comes out to be simple...may be we can use it in future projects. But the issue is that i am not getting good help from anywhere...i am reading the documentation. Some more information can be very useful.
Please take out some time to explain more. Are you using JMesa as well for some application ? said...

Yep, I use JMesa in some projects. I'll try to write some more when I have enough time.

Anonymous said...

boss why r u fooling people wher is ur jmesa code.

geetha said...


Is there any option to change the filter cell?? Since the filter cell looks like textbox, filter option is not obvious to the user.. Can anybody help me If its possible to change it.

Anonymous said...

Excuse me, can you say more about this row?
(request.setAttribute("frameworks", frameworks);)
Where you defined request object.

Popular Posts