May 4, 2008

Offtopic: A picture of the sky

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) {
this.name = name;
this.url = url;
this.license = license;
this.like = like;
}
public String getName() {
return name;
}
public String getUrl() {
return url;
}
public void setName(String name) {
this.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) {
this.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", "http://jquery.com", "MIT & GPL", true);
Framework mootools = new Framework("Mootools", "http://mootools.net/", "MIT License", true);
Framework gwt = new Framework("Google Web Toolkit", "http://code.google.com/webtoolkit/", "Apache License", false);
Framework dojo = new Framework("Dojo", "http://dojotoolkit.org/", "BSD & AFL", false);
Framework prototype = new Framework("Prototype", "http://www.prototypejs.org/", "MIT License", false);

ArrayList frameworks = new ArrayList();
frameworks.add(jquery);
frameworks.add(mootools);
frameworks.add(gwt);
frameworks.add(dojo);
frameworks.add(prototype);

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.

May 2, 2008

One annoying problem with jquery, ui.dialog plugin and Firefox

I have run into a small problem with jquery, ui.dialog and Firefox 2. If you just use the example code and the default plugin theme (flora) you will see the problem with Firefox - the middle of the dialog is empty. With IE 6 everything is working just fine. I spent some time pushing my head, trying to solve the problem. And then I came across the solution – the example that comes with the ui.dialog. The only difference with my code was the body tag that has class property. Just a css issue, not a dialog problem.
Quite nasty thing, not a bug, but it is not pleasant to make everything from the documentation and don’t get it working.

Sweating on a Web 2 Application

Have you asked yourself what is a good Web 2 application? What should it contain and what can be permitted to the users. I am working on a private configuration application, and I want to make it really useful for the users. Not just fancy picture sliding with JavaScript, in the matter of facts I don't have any pictures, but I have a lot of fancy JavaScript. My own opinion is that Java is the maturest language/technology for this kind of task. Java with Hibernate, Struts or maybe Spring. And of course JavaScript(give me a brake) for client scripting. JavaScript with JQuery, Mootools, Dojo or GWT. My personal liking goes for Mootools, but JQuery is a little more professional.

Strange exception

There is a new cry topic in one of the development forums I read, that make me think about this problem of the tomcat application server. The problem is about ojdbc14.zip(or any zip) in a web application. The exception was

org.apache.jasper.JasperException: JDBC Driver class not found: oracle.jdbc.driver.OracleDriver

despite the fact that ojdbc14.zip was in the project lib directory. I've just remembered how much time I spent on a similar problem, so I send him my answer. The reason for this bug is that tomcat have problems with zip archives. Renaming to jar will fix it. I haven't tested if the latest tomcat have zip problem though.

Popular Posts