Friday, 27 August 2010

Google AppEngine, Apache Click and NetBeans - Part 2

I have finally managed to get my Hello World application working with Apache Click on AppEngine.

See my previous post which explains how to obtain and compile the latest click libraries here. I did that because I eventually want to try out the ClickClick extensions for Click and their documentation says you need Click Version 2.3.0. However, I am starting to question that, because other parts of the documentation seem out of date.

I am using NetBeans 6.9 with the NBAppEngine plugin. You need to have the AppEngine SDK installed, too.

1. Start a new project using File -> New Project and select category Java Web and project Web Application

2. In the second step, give your project a name, and click next to go to the third step. From the list of servers choose Google App Engine.

3. You do not need to select any frameworks in step 4. When you click Finish your project should look like the one below.

4. To make this a Click project, add the click libraries. Right-click on the Libraries folder and select Add JAR/Folder and select click-2.3.0-M1.jar and click-extras-2.3.0-M1.jar from wherever you saved them.

5. In the Web Pages\WEB-INF folder create a new XML document called click.xml. Later we will create the helloworld.htm view, and the controller class HelloWorld.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE click-app PUBLIC
       "-//Apache Software Foundation//DTD Click Configuration 2.2//EN"


      <page path="helloworld.htm" classname="clicktest.HelloWorld"/>

  <mode value="debug"/>


6. Edit the web.xml file

<?xml version="1.0" encoding="UTF-8"?>
    xmlns="" id=""


7. Edit the appengine-web.xml file to exclude *.htm files from the list of static file types. See the click documentation for the GoogleAppEngineListener class for more details.

<?xml version="1.0" encoding="UTF-8"?>
     <!-- Exclude *.htm files from being served as static files by GAE,
             because the *.htm extension is mapped to ClickServlet. -->
         <exclude path="**.htm" />

8. In Web Pages, delete index.jsp and create helloworld.htm. The body of the page should look like this:

    <h2>Hello World</h2>

    Hello world from Click at $time

9. Create a new package clicktest with a class HelloWorld

package clicktest;

import java.util.Date;

public class HelloWorld extends Page {

    private Date time = new Date();

    public HelloWorld() {
        addModel("time", time);


10. Your project should look like this. Click Run and it should work!

No comments:

Post a Comment