Getting started with Apache Click and Eclipse Galileo
Last couple of days I read here and there about Apache Click, which is now in version 2.1.0. It looks preety cool and easy to learn, so I decided to give it a try and see for myself.
I understand that its cool to learn things using vi and shell only, but when you tried many frameworks before, you know how things works, you just want to see how or how not, productive you can be with the new framework, thats why I jump straight to the IDE.
And here, first surprise, with apache click its’ not that easy, well, I’m mean its still easy but I have encountered a few problems, and right now I would like to share the solution.
First of all, I did not tried all the examples in the apache click user guide yet, haven’t build anything usefull and definietly I’m not an Apache Click expert, I think I have figured out how to plug it to Eclipse and I think this is good start :).
Here you have a few points to build your Apache Click IDE:
1. First of all download latest and greatest Eclipse Galileo from here – choose Eclipse for Java EE developers
2. Download Apache Click libraries from here – choose version 2.1.0
3. Download Apache Click IDE from here – note that it contains Click version 1.5 and it was last updated in November 2008 – maybe I’m missing something here?
4. Unzip your ClickIDE and copy the ‘features’ and ‘plugins’ folders into your Eclipse home directory
5. Unzip your latest click libraries and keep it for later 🙂
6. Start your Eclipse IDE and create new ‘Dynamic Web Project’
Choose target name, in this case ‘ClickDemo2’, select your target runtime as Tomcat 6+ etc.
7. Under configuration combo box, select custom and click ‘Modify’
8. Select ‘Click’ in Project Facet List and save the configuration as click config
9. Once you have your configuration created, dynamic web project screen should look like in the following screenshot:
10. The rest of the settings you can leave as it is, just click ‘Next’ up to the point when you finish creating new dynamic web project.
11. After your project is created it will have the structure like in the following screen:
Notice that there are click libraries from version 1.5, which is no good, we want to use the latest version which is 2.1.0.
12. Copy the files ‘click-2.1.0.jar’ and ‘click-extras-2.1.0.jar’ into the same lib folder where the old libraries are found.
13. Delete old libraries and refresh the project tree under eclipse (right click on the project node and select ‘Refresh’), now you will see the new libraries come up in the lib folder.
14. Open your web.xml file under ‘WebContent/WEB-INF/’ folder and change the class name of the main Click Servlet, from ‘net.sf.click.ClickServlet’ to ‘org.apache.click.ClickServlet’ in ‘servlet-class’ declaration.
15. With Eclipse, select the project node and click ‘New’ -> ‘Other’, choose ‘Click Page’ under ‘click’ directory.
16. Fill out the necessary fields for your new click page as below:
17. Name the file ‘index.htm’ and click ‘Finish’
18. Under the page java source file, fix the Page class by using the page from the: org.apache.click.Page instead of the old path.
import java.util.Date;
import org.apache.click.Page;
public class Index extends Page {
private Date time = new Date();
public Index(){
addModel("time", time);
}
}
Modify your ‘index.htm’ using html editor to look something like this:
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=UTF-8">
<title>Blank</title>
$imports
</head>
<body>
$time
</body>
</html>
19. Start up your project in tomcat. The page should display current time!
Additional Comments:
I know that this is just a quickfix, and I just cannot belive that there is no proper eclipse plugin using the latest click framework, which would be up to date, if you know any, than please comment and save me and my readers precious time.
Thank you.
Hi,
I believe a new version of ClickIDE targeting Click 2.1.- will be rolled out fairly soon. You can find a build here:
http://people.apache.org/~takezoe/click/clickide/2.1.0.0/
Kind regards
Bob
Great!
Will check it out!
10x
Very nice tutorial!
Muy bueno el tutorial!!
gracias
great tutorial about Galeo