Archive for Java

Wicket first contact

While working on an AJAX web application a couple of weeks ago, a co-worker asked me what I know about Wicket. Not much at that time. I knew it was some kind of component based web framework, but only in the sense like everybody knows that Porsche is a German car brand.

During the recent holidays I spent the entire time away from work and with my family. As most of the time when I’m away from work I made a list of things to look at. Wicket was not on that list. I seldom make it at least half way thru that list anyway. It was the same this time. But then I saw this article on TheServerSide about the release of Wicket 1.3. The big amount of comments caught my interest. Suddenly, Wicket was on that list.

Today, I downloaded and installed Wicket, and then looked for documentation and tutorials. Besides some interesting online resources, I found the combination of two books on Wicket the most helpful:

The first book seems a little more verbose than the second book and covers more background, while the second book (besides being more complete right now) has much more source code examples. They complement each other perfectly in my opinion. So I got them both.

After reading thru the first three freely available chapters of “Enjoying Web Development with Wicket”, I got interested in chapter 6 (Supporting Other Languages). I was really impressed to see how I18N is a first class citizen in Wicket.

Screenshot from the Cheesr sample application

I then turned to “Wicket in Action”. Right now it is not completed and contains many errors, but none of this is really a problem. I made it thru the chapters 1-4 and implemented the Cheesr sample application (from chapter 4) along the way.

I really like what I’ve seen so far from Wicket:

  • It’s component based and encapsulates the request/response cycle
  • Components seem easy to write
  • Good internationalisation concept
  • Separation from logic and presentation

Right, I’ve barely scratched the surface yet, but Wicket as a web framework looks promising.

Comments

Why I upgraded to GWT 1.4.61

The previous version GWT 1.4.60 came out on August 27th, 2007. A couple of days later I had upgraded all my applications, the expression calculator demo too. None of the applications suffered from a strange bug except the demo. It appeared only when Microsoft’s Internet Explorer was used. A message box was displayed that told the user: “operation aborted”. The page wasn’t shown at all, the user only saw a blank page. I had to remove the demo, at least from the home page. Since only the demo was affected, I didn’t go back to GWT 1.4.59.

Three days after GWT 1.4.60 came out, the issue was reported, approximately at the same time I was experiencing it. I was hoping for a quick fix, but it didn’t come.

Several month later, Google’s Scott Blum wrote in the GWT forum about an updated GWT 1.4 release. Although I read the forum quite regularly, I nearly missed his posting. He talks about the new release fixing the problem, and he also provides a download link for GWT 1.4.61. I’ve downloaded it and upgraded all my application without a problem so far.

Google Web Toolkit 1.4.61 is available for download

Since it fixes a very serious problem, you should upgrade also. Problem is, you will not see the new version on the GWT download page. At least not yet, but I bet you will see it there shortly. In the meantime, just use this link.

Update: It took a little bit longer than I expected, but the GWT Team has just officially released GWT 1.4.61, which takes care of some minor bugs in the previous release of GWT 1.4.60. The two main issues that were addressed are the “operation aborted” startup error on IE and a potential XSS vulnerability in hosted mode.

There are no differences between the 1.4.61 version released on December 12th, 2007 and the 1.4.61 version released on November 3rd, 2007.

Comments

A small GWT application

I had some time today, so I built a little AJAX application for this blog. It’s an expression calculator. The world really doesn’t need another one, but it was the easiest thing that includes ANTLR for building a lexer/parser/AST and the Google Web Toolkit for building the client. Why? Because it’s fun …

If the application doesn’t load, please click here!

Before I was able to include a GWT application within a post in this WordPress powered blog, I had to create a WordPress plugin that generates the necessary meta tags. GWT applications only work, when those meta tags are present.

The actual calculation of the expression is done on the server with the help of my Java based framework. The expression is sent to the server asynchronously as a JSON data packet. The server logic evaluates the expression and sends back either the result, or an error message. If you want to see an error message, try a division by 0. The response is sent also in the JSON format back to the browser, where the GWT application takes it and displays it without refreshing the whole page.

The server side logic is built with the help of ANTLR and ANTLR Studio for Eclipse. Instead of writing a lexer and parser for evaluation of the expressions myself, I’ve used a grammar to let these tools do it for me. The following screenshot shows ANTLR Studio for Eclipse in action:

Eclipse screenshot with ANTLR Studio

If you want to know what ANTLR is, here is a quote from Terence Parr, the primary author of ANTLR. He has been working on translation tools since the late 80s:

ANTLR, ANother Tool for Language Recognition, (formerly PCCTS) is a parser and translator generator tool, akin to the venerable lex/yacc duo, that lets you construct recognizers, compilers, and source-to-source translators from grammatical descriptions containing C++ or Java actions. You can build translators for database formats, graphical data files (e.g., PostScript, AutoCAD), text processing files (e.g., HTML, SGML), etc. ANTLR is designed to handle all of your translation tasks. ANTLR is recommended by the co-inventor of LL(k) parsers and by the inventor of SLR(k) and LALR(k) parser.

Another tool makes generation of GWT clients easier. It’s the GWT Designer from Instantiations. I’m having a few problems with it, but it still helps a lot. See the following screenshot for an impression:

Eclipse screenshot with GWT Designer

If you’re interested in this example built with GWT, ANTLR, JSON, etc., and you want to look at the source code, just download it from here.

Do you remember the little problem from the Geometry for kids post earlier today? With the calculator, you can verify if the solution is correct: d = sqrt(3)*5.3.

Update: As of GWT 1.4, a new application-loading mechanism has been introduced, that doesn’t require a meta tag in the page header. It’s still supported for legacy applications. But now, the applications HTML code can directly reference the JavaScript file. I’ve changed the example above accordingly.

Comments (1)

All GWT components now Open Source

The Google Web Toolkit team has announced Google Web Toolkit Version 1.3 Release Candidate on the Google Web Toolkit Blog and the Official Google Blog. There have been no code changes since GWT Version 1.2, but all of the source code for GWT has been released under the Apache 2.0 license. This means that the core Java-to-JavaScript compiler and the hosted mode debugger are now available under the same Apache 2.0 license. Previously, only the user libraries were published under that license.

I very much welcome this step by Google. But they need to do something else, too. As someone on Google Web Toolkit Online Group pointed out, Google needs to build a major application with GWT. And they need to do it soon. This will help everybody who has to make a decision for GWT that is not based on its technical merits alone.

Comments

New GWT Release 1.2.22

The Google Web Toolkit has a new stable release. You can read all about it here. It will be used for the new synformation web site, too.

I’ve started to use GWT since version 1.0 came out (August 25, 2006). It was easy to use and since I’m not very good at JavaScript programming, leave alone all the little things you have to know to make sure your JavaScript is compatible with all the different browsers, it was the right thing for me as a Java developer.

Integration with synformation is easy. I don’t use GWT’s RPC mechanism, but the JSON format for client-server communication. GWT finally supports sending requests with content-type application/x-www-form-urlencoded, which is how it’s normally done. On the server side, I can now use request.getParameter() instead of having to read the posted data directly. It’s really not a big deal, but more convenient. The new module com.google.gwt.http.HTTP provides the necessary functionality.

I’ve written a quick example. It’s available here. It sends formatting instructions to the server via JSON. The server formats the current time and sends the text back to the client. The relevant portion of the page is updated to display the current server time. Note that not the whole page is updated, only the text with the server time. That’s because client-server communication is done asynchronously in the background. Although it’s only a small example, it already has the complete communication architecture for RIAs.

Comments

« Previous entries