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!!


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"

    <to type="forward">/content.html?contentId=$1</to>
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"

  <!-- No Query String -->
    <to type="forward">/content.html?contentId=$1</to>
  <!-- With Query String -->
    <to type="forward">/content.html?contentId=$1&$2</to>
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.


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(){
      AjaxRequestButton.ON_COMPLETE, "displayResult");
  public boolean getAllBooks(){
    List<Book> books = bookService.getAllBooks();
    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(){
  public boolean onSearch(){
    List<Book> bookList = bookService.search(keyword.getValue());
    return false;
Of course, these controls need more improvement. However I think this concept matches to Click Framework well.


S2Click: Seasar2 integration for Click Framework

S2Click is Seasar2 integration for Click Framework. Seasar2 is an opensource DI container made in Japan. S2Click adds powerful features to Click.
  • HOT deploy - You don't have to restart application server when you modify your sourcecode.
  • Java5 annotation - S2Click provides some annotations for ease of development
  • Ajax & File download support - The page base class S2ClickPage provides methods to render Ajax & file downloading response.
  • public field handling - You can use public fields instead of setter & getter in many places.
  • Extended controls - S2ClickForm, ToolTip, ConfirmSubmit, AjaxLinks and AjaxButtons
Now, Seasar2 and S2Click focuses to Japanese developers (So documentation is provided with Japanese mainly).

However I will introduce S2Click detailed features in this blog. And also I will feedback these features to Click Framework from S2Click in the feature.


Click Framework goes to ASF!

There are very good news. Click Framework will join to the Apache Incubator! The proposal has been accepted.

This is the first step of introducing Click Framework to many Java developers. I'll make effort to incubate Click Framework in the Apache Incubator.


AIR GEAR 1.0.0 Released!

Yesterday, Project Amateras released AIR GEAR 1.0.0!

AIR GEAR is an open source IDE for Adobe AIR development. It works as an Eclipse plug-in so you can use it with many other Eclipse plug-ins and powerful features of Eclipse.

AIR GEAR has following features:

  • Supports both HTML and Flex based AIR application development
  • WISYWIG graphical editor for Flex
  • Automatic build and error reporting
  • AIR application launcher on the Eclipse

See this page about detailed use.

Enjoy your development!


memcached in Java

I'm looking for memcached client library for Java. Then I found two libraries.
memcached client for java
memcached client for java is simple and synchronous mamcached client libraries. This is easy to use but not support CAS commands.
spymemcached supports asynchronous processing and CAS commands. Updating cache is high-speed. However implementation is very complex.
I think that many web applications don't require asynchronous cache processing. So I think mamcached client for java is better solution.


prototype.js and script.aculo.us

The next version of Amateras JavaScript editor supports prototype.js and script.aculo.us. These libraries are proposed in code completion proposals.

In the future version, many other JavaScript libraries will be supported!

The page auto mapping without templates

Click Framework provides the page auto mapping. This is the important feature to decrease amount of configuration.

However Click maps page classes to request-path from HTML templates. So page classes which do not have corresponded HTML template is not mapped automatically.

For example:

  • pages which share a HTML template
  • the page which returns JSON or file (response is written in the page class)
I'm thinking about annotations on Click Framework. How about the @Path annotation which specifies the auto mapping path to page classes.
public class FileDonwloadPage extends Page {

   * Writes response for file downloading in this method.
  @Override public void onRender() {
    HttpServletResponse res = getContext().getResponse();
    OutputStream out = res.getOutputStream();

   * This method returns null to not render template,
   * because this class writes response contents for file download.
  public String getPath(){
    return null;
This is one idea of using annotation in Click Framework.


JavaScript Formatter

EclipseHTMLEditor (a part of Amateras) provides the JavaScript editor. I added JavaScript source code formatter to the JavaScript editor. We can format JavaScript source code from the context menu.

Please wait for the next release of EclipseHTMLEditor!


JJUG Cross Community Conference 2008 Spring

JJUG Cross Community Conference 2008 Spring will be held at Japan 30 Apr.

JJUG is an abbreviation of Japan Java User Group. In this conference, top Java engineers in Japan talk about hot topics in Java such as Web frameworks, EclipseLink, JAM, Scala and New Swing APIs.

I'll talk about Click Framework in this conference and join panel discussion with speakers of Grails, JRuby on Rails and Wicket.

I wish to make efforts to spread Click Framework in Japan.


File download in Click Framework

Click Framework provides FileField to upload file, however Click does not provide any support for file downloading. I made AbstractDownloadPage to download file.


 public class SampleDownloadPage extends AbstractDownloadPage {
  public SampleDownloadPage(){

This page class does not have a template because response is written by this class. So auto-mapping does not work for file download pages. The extended page class have to be registered to click.xml.


Click Framework + LiveValidation

Click controls provide JavaScript validation, but they are not easy to customize. Now I'm writing JavaScript validation framework for Click using LiveValidation. In the page class, ready the LivaValiator control like below:

Form form = new Form("form");
form.add(new TextField("name", true));
form.add(new PasswordField("password", true));
form.add(new Submit("login"));

addControl(new LivaValidator("validator", form));

In the page template, generates LiveValidation JavaScript code by the LiveValidator control:

  <script type="text/javascript">

We can also add customized validation rules by use of Validate.Custom.


OVal: The simple validation framework for Java

OVal is the simple validation framework for Java. You can specify validation rules using annotations.

public class Person {
  public String name;


Validator v = new Validator();

Person p = new Person();
for(ConstraintViolation error: v.validate(p)){
OVal can switch validation rules by profiles.
public class Person {
  public String name;
  @NotNull(profiles={"profile1", "profile2"})
  public String email;

Switch profiles like following:

// Enable all profiles
// Enable a specified profile

// Disable all profiles
// Disable a specified profile


JSONIC - simple json encoder/decoder for java

JSONIC is a simple JSON encoder / decoder for Java made in Japan. We can get JSONIC from http://sourceforge.jp/projects/jsonic/files/. The use of JSONIC is very easy.

import net.arnx.jsonic.JSON;

String text = JSON.encode(new Hoge());

Hoge hoge = JSON.decode(text, Hoge.class); 

JSONIC can handle POJO's public fields as property well and it also encode / decode java.util.Map and java.util.List.

I recommend JSONIC if you have to handle JSON in Java. It would be a best choice.

The First Seasar2 Example

At first, I show the very simple example to use S2Container. I created following 3 files into "jp.sf.amateras.seasar.example" package.


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE components PUBLIC "-//SEASAR2.1//DTD S2Container//EN"
  <component class="java.util.ArrayList" name="list">
    <initMethod name="add"><arg>"Naoki Takezoe"</arg></initMethod>
  <component class="jp.sf.amateras.seasar.example.Hello" name="hello">
    <property name="target">list</property>


package jp.sf.amateras.seasar.example;
import java.util.List;

public class Hello {
 private List target;
 public void setTarget(List target){
   this.target = target;
 public void sayHello(){
   for(int i=0;i<target.size();i++){
     System.out.println("Hello, " + target.get(i));


package jp.sf.amateras.seasar.example;
import org.seasar.framework.container.S2Container;
import org.seasar.framework.container.factory.S2ContainerFactory;

public class Main {
 public static void main(String[] args){
   S2Container container = S2ContainerFactory.create(
   Hello hello = (Hello)container.getComponent("hello");

Run the "Main" class as a Java application, it displays "Hello, Naoki Takezoe".


S2Dao: 2-Way SQL

S2Dao can assemble dynamic query using SQL comment. For example:

@Sql("SELECT * FROM emp WHERE empno = /*empno*/7788")
public Emp selectEmpByEmpNo(int empNo);

/*empno*/ replaces the given argument and 7788 is removed by S2Dao at runtime. We can execute this SQL without no modification with the database client software such as psql. This solutuion is called "2-Way SQL" in S2Dao.

We can also use IF..ELSE statement as SQL comment.

/*IF hoge != null*/hoge = /*hoge*/'abc'/*END*/

And see the following example. If all conditions are false, S2Dao ignores /*BEGIN*/ ... /*END*/ block. So WHERE phrase is removed when it's not needed.

  /*IF job != null*/job = /*job*/'CLERK'/*END*/
  /*IF deptno != null*/AND deptno = /*deptno*/20/*END*/

Again, these SQL can be executed with database client software with no modifications. 2-Way SQL makes possible to test SQL easily.


S2Dao: The most powerfull database access framework

S2Dao is a database access framework based on the Seasar2 and AOP solution. Today, I introduce this great framework to you.

S2Dao makes DAO from Java interface using AOP at runtime. We have to write only Java interface such as:

public interface UserInfoDao {
  public List<UserInfo> selectAllUserInfos();
  public void insertUserInfo(UserInfo userInfo);
  public void updateUserInfo(UserInfo userInfo);
  public void deleteUserInfo(UserInfo userInfo);

SQLs are generated automatically by the entity definition (which is specified by @S2Dao) and DAO method names. So we don't have to write SQL in simple cases such as CRUD to the single table.

Of course, we can use complex SQL instead of auto generated SQL. We can specify WHERE and ORDER BY using @Query:

public List<UserInfo> selectUserInfoByDeptId(int deptId); 

And using @Sql, we can specify all parts of SQL:

public int getCount(); 

These are parts of S2Dao great features. If we have to use complex and large SQL, we can write it as an external SQL file named "classname_methodname.sql" and S2Dao also support dynamic query using SQL comment. I will talk about them as another entries.

This is the first entry in Blogger!!

This is the first entry in Blogger!!

I'm making a lot of Eclipse plug-ins at the Project Amateras. Eclipse is the major open source Java Integrated Development Environment. And I'm also commiter of the Click Framework. Click is powerful and simple web application framework for Java.

Now I'm interested in the small web development project using Java. Which frameworks should we use...? My one answer is here:

  • Seasar2 (DI/AOP container made in Japan)
  • S2Dao(Data Access Framework based on Seasar2)
  • Click Framework

Seasar2 is a poweful DI/AOP container made in Japan. I think Seasar2 is more easy than Spring in many cases. However Seasar2 does not have enough English docuements to use it. So I will try to tell about Seasar2 in this blog.