8/24/2009

JSDT: JavaScript Debug Tool

JSDT(JavaScript Debug Tools) is a JavaScript debugger that supports multi web browser without any add-ons.

Existing JavaScript debugger such as Firebug works for only specific web browsers or requires special add-ons. However JSDT has no requirement. It supports IE, Firefox, Chrome, Safari, Opera and many other browsers.

It works as the HTTP proxy server and this proxy inserts JavaScript code for debug into original JavaScript code. Inserted code sends debug information to debugger using Ajax.

JSDT provides a Swing based stand-alone debugger and an Eclipse plug-in. We can choose them by our development style.

Now, JSDT has some problem to debug JavaScript which contains multi-byte characters. So the current version is not so practicable. However JSDT's debugging mechanism looks epoch-making. I'm looking forward to the future of JSDT!

7/26/2009

Utility to use JDO easily on Google App Engine

We can use JDO to access BigTable on Google App Engine for Java.

However JDO PersistenceManager and Query object are so complex. So I wrote an utility to use JDO easily. For example, you can search entities as follows instead of JDO Query object.

List entries = JdoUtil.from(Entry.class)
  .filter("userId == ?")
  .ordering("updateDate desc")
  .range(0, 20)
  .getResultList(userId); 

No need to cast result objects and Query#declareParameters() also.

I would like to provide this utility in the part of my NikoNiko Framework (NikoNiko means Smile in Japanese). NikoNiko Framework supports both standard JavaEE web development and Google App Engine for Java. It's small and lightweight. It would be suitable for the small web application development.

4/03/2009

Empire-db: Type-safe query builder

I found a new database access framework named Empire-db in the Apache Incubator.

A most important feature of Empire-db which I think is a type-safe query builder. See a following example from Empire-db's web site.

// Create a command object
DBCommand cmd = db.createCommand();
// Select columns
cmd.select(EMP.EMPLOYEE_ID);
cmd.select(EMP.LASTNAME.append(", ").append(EMP.FIRSTNAME).as("NAME"));
cmd.select(DEP.NAME.as("DEPARTMENT"));
// Join tables
cmd.join  (DEP.DEPARTMENT_ID, EMP.DEPARTMENT_ID);
// Set constraints
cmd.where(EMP.LASTNAME.likeUpper("Foo%"));
cmd.where(EMP.RETIRED.is(false));
// Set order
cmd.orderBy(EMP.LASTNAME);
cmd.orderBy(EMP.FIRSTNAME); 
This feature is very useful at the software development projects which face many changes of database schema. Because compilation errors are caused by changes of database schema. We can fix these errors completely and surely soon.

1/02/2009

Toggle comment in the Velocity editor

I've just start development of the next version of ClickIDE.

I added Toggle Comment action to the Velocity editor. You can toggle comment for selected lines by the context menu or CTRL + /.

By the way, Now I'm planning JSP and FreeMarker support in the next version of ClickIDE. I have no concrete idea yet, but I wish to provide FreeMarker editor which has features same as the Velocity editor.

11/12/2008

ClickIDE 2.1.0 Released

ClickIDE 2.1.0 is now available!

ClickIDE is an Eclipse/WTP plug-in for web application development using Click. This release has not new features however it supports Click 1.5 and Eclipse 3.4/WTP 3.0.

Please download ClickIDE 2.1.0 and enjoy Click!!

10/08/2008

Url Rewrite Filter: Make Clean URL in Click Framework

Url Rewrite Filter is a servlet filter which provides features similar to the mod_rewrite. We can make clean URL in Click Framework using Url Write Filter.

Url Rewrite Filter has a configuretion file WEB-INF/urlrewrite.xml. This is a very simple example of clean URL with a Click application.

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite
  PUBLIC "-//tuckey.org//DTD UrlRewrite 2.6//EN"
  "http://tuckey.org/res/dtds/urlrewrite2.6.dtd">

<urlrewrite>
  <rule>
    <from>^/contents/([0-9]+).htm$</from>
    <to type="forward">/content.html?contentId=$1</to>
  </rule>
</urlrewrite>
For example, Url Rewrite Filter will forward /contents/001.htm to /content.htm?contentId=001.

If content.htm has possibility to receive any other query parameters, we can define following rules.

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite
  PUBLIC "-//tuckey.org//DTD UrlRewrite 2.6//EN"
  "http://tuckey.org/res/dtds/urlrewrite2.6.dtd">

<urlrewrite>
  <!-- No Query String -->
  <rule>
    <from>^/contents/([0-9]+).htm$</from>
    <to type="forward">/content.html?contentId=$1</to>
  </rule>
  <!-- With Query String -->
  <rule>
    <from>^/contents/([0-9]+).htm?(.+)$</from>
    <to type="forward">/content.html?contentId=$1&$2</to>
  </rule>
</urlrewrite>
Of course, we can use Url Write Filter with other frameworks such as Struts. I think Url Write Filter is a simple solution to make clean URL in the Java web applications.

8/15/2008

Ajax Controls for Click Framework

I'm thinking about Ajax integration for Click Framework recently.

For example, see the below page class. If you clicks AjaxRequestButton, Click invokes getAllBooks() using XMLHttpRequest. And getAllBooks() renders a Java object as JSON. AjaxRequestButton generates a HTML button that invokes Ajax.Request of prototype.js.

public class AjaxPage extends AjaxPage {
  public AjaxRequestButton button
    = new AjaxRequestButton("search", this, "getAllBooks");
  
  public AjaxPage(){
    button.addAjaxHandler(
      AjaxRequestButton.ON_COMPLETE, "displayResult");
  }
  
  public boolean getAllBooks(){
    List<Book> books = bookService.getAllBooks();
    renderJSON(books);
    return false;
  }
}
Next example. AjaxSubmit control send Form using Ajax.Request.
public class AjaxPage extends AjaxPage {

  public Form form = new Form("form");
  private TextField keyword = new TextFiled("keyword");
  private AjaxSubmit search = new AjaxSubmit("search", this, "onSearch");
  
  public AjaxPage(){
    form.add(keyword);
    form.add(search);
  }
  
  public boolean onSearch(){
    List<Book> bookList = bookService.search(keyword.getValue());
    renderJSON(books);
    return false;
  }
}
Of course, these controls need more improvement. However I think this concept matches to Click Framework well.