Forgot your password?
typodupeerror

Practical Ajax Projects with Java Technology 98

Posted by samzenpus
from the more-ajax dept.
Simon P. Chappell writes "Is there anyone left in our industry that hasn't heard of Ajax, the ultimate client-side technology for web developers? Like many, I've read several books on it and now I'm even brushing up on JavaScript so that I can try it out. There is, however, an aspect of Ajax that often seems to get lost in the rush to play with the new browser tricks; Ajax enhanced web applications still need to work closely with server-side components. To even up the balance of books that concentrate on the browser end of Ajax, Apress brings us Practical Ajax Projects with Java Technology by Frank W. Zammetti.
Practical Ajax Projects with Java Technology
author Frank W. Zammetti
pages 504 (16 page index)
publisher Apress
rating 9 out of 10
reviewer Simon P. Chappell
ISBN 1590596951
summary A useful and practical book for those wishing to write web applications that combine Ajax front-ends with Java technology on the server-side.


This is a book for anyone developing web applications with Java server-side components. It does assume a minimum level of Java ability, but not that you should know any specific frameworks. If you know basic Servlet and JavaServer Page programming, then you'll be fine for working your way through the frameworks presented in the book.

The book is divided into two parts. The first part is just three chapters and covers the principles of programming using Ajax and Java. Chapter one is the "hurrah for Ajax", obligatory examples and brainwashing. A discussion of the "classic web" and its problems leads into examples of the new web and Ajax enhanced websites. Chapter two is an introduction to the technologies behind Ajax for those who may be less familiar with JavaScript, the DOM, XML and parsing XML using JavaScript and Cascading Style Sheets (more usually known by its acronym CSS). Don't expect to learn these technologies from scratch out of this chapter, but if you have some amount of exposure to them, it will remind you of all the bits that you'll need for Ajax. Chapter three then does a similar thing for the server-side Java technologies. Again, if you snoozed through Java classes at school, don't expect this to get you caught up, but it will refresh your memory on the useful pieces.

The second part of the book holds the seven example projects. These are the meat of the book, given that the title promises practical projects and I think that the book pretty much delivers on its promise All seven projects are interesting; six are practical and the last one is just good old fashioned fun. The projects build in terms of size, so the first one is the simplest and the game, coming last is the most complex. The first project is a type-ahead suggestion engine, modeled after Google's Suggest. Next we have an Ajax-based webmail client. Chapter six builds a RSS newsfeed reader (because, as the book says, every Ajax book has to have one). Chapter seven is a photo sharing application, which, while it may not compete with Flickr, is quite usable for its size. Chapter eight is an organizer. Umm, needless to say you'll either love this or ignore it. (What can I say? If I was organized enough to use an organizer, I'd be organized enough not to need it!) Chapter nine brings yet another chat program to the world.

Last, but as the phrase goes, not least, chapter ten is the grand finale of the example projects. As befits the author's fine sense of humor, the final project is a game; Ajax Warrior! This application has graphics designed by a professional graphic artist and looks far above any other example application that I've ever seen.

As soon as I saw that Mr. Zammetti had written a book, I rushed to be the first to volunteer to review it. This will need no explanation to members of the Struts mailing list, but for the rest of you it might help if I explain that he is that wonderful combination of a funny and helpful guy. I knew that anything he wrote was going to be first rate technically and was also going to be written in a light and relaxed style; always a winner in this kind of book.

I liked the fact that Mr. Zammetti covers a number of approaches to writing both the client and server-sides of the applications. For the server-side of a number of the applications, he uses plain JavaServer Pages, yet for others he uses industry-leading frameworks including WebWork and Struts. On the client-side he continues to mix it up, with some applications using "naked" Ajax, others using DWR, AjaxTags from Java Web Parts, DWR, Dojo, JSON and Prototype.

One more thing to like about the book is that the applications actually look very nice and quite professional. Perhaps the folks at 37signals shouldn't be nervous, but Mr. Zammetti has certainly raised the bar for the appearance of example applications for books.

The flip side of the use of multiple frameworks and Ajax libraries is that all of the breadth means reduced depth. Each of the frameworks and libraries is introduced and demonstrated, but then just as it begins to get interesting, it's off to the next one. If you're looking for more depth in each introduced item, then this book may not be for you.

In conclusion, this is a useful and practical book for those wishing to write web applications that combine Ajax front-ends with Java technology on the server-side. Strongly recommended.


You can purchase Practical Ajax Projects with Java Technology from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
This discussion has been archived. No new comments can be posted.

Practical Ajax Projects with Java Technology

Comments Filter:
  • Re:Hear! Hear (Score:3, Informative)

    by AKAImBatman (238306) * <akaimbatman@gmai ... m minus language> on Monday October 23, 2006 @03:22PM (#16551216) Homepage Journal
    Did you know that javascript will go ahead and add a closing select tag for you

    What were you expecting it to do? Once you give the HTML to the browser, it attempts to parse it, add it to the DOM, and render it. It can't do that if you've still got open tags. So it assumes that you forgot to close your tag, and closes it. The exact same thing would happen if you accessed the DOM through Java, C/C++, or any other language.

    This just goes to show the problems with the innerHTML psuedo-standard. People think that HTML consists of a bunch of strings, when it's actually a complete Object model that we are able to store serialized versions of. While innerHTML can be convenient for even the experts, it's going to do strange things if you don't understand what you're doing.

    If you didn't understand a word of that, then I recommend that you visit your friendly standards organization [w3c.org] and start reading. Until you understand exactly what you're doing, you are in an unfit state to program DHTML constructs. Trust me, you WILL regret it later if you don't get the basics down NOW.

    Since someone else posted the proper DOM answer to your issue, here's the innerHTML answer:
    var code = '<select name="whatever">';
     
    for(var i=0; i<myoptions.length; i++)
    {
    //Tailor for your code
        code += '<option name="option'+i+'">'+myoptions[i]+'</option>';
    }
     
    //As of right here, "code" is still a String object.
     
    //Here we add it into our DIV. The browser will parse the HTML, and create a renderable object model out of it.
    mydiv.innerHTML += code;
  • Re:AJAX problems (Score:5, Informative)

    by Civil_Disobedient (261825) on Monday October 23, 2006 @04:00PM (#16551834)
    Everyone is out rushing to build AJAX apps into even the simplest applications, and the result is slow loading time and greatly increased server loads.

    While this no doubt happens all the time, the main advantage of AJAX-enabled web applications is reduced load on the server. For instance, our intranet application uses the Tapestry framework, and the built-in tables component (at least for the 4.0 version) was useless because it required constant, complete page refreshing when all you really wanted to update was the contents of a table. We rolled our own table component that's fully ajaxificated and it's been nothing but positive for our end users and our servers.
  • by jgertzen (975712) on Monday October 23, 2006 @05:29PM (#16553090) Homepage
    DISCLAIMER:I am the lead architect of the ThinWire RIA Ajax framework, therefore proceed with your filters on if you wish ;-)

    I think you have that backwards. For anything but the most trivial of Ajax programming, you should use an existing framework. Trivial examples fall into what the Gartner group classifies as "Ajax Snippets" http://www.adtmag.com/article.aspx?id=17953 [adtmag.com], which are simply quick hacks onto an existing web applications. And really, if you're adding a lot of snippets to your existing web application you should still use something like Prototype http://prototype.conio.net/ [conio.net].

    Sure, the basics of XMLHttpRequest (XHR) are straight forward and can be mastered by anyone. And sure, you can hack the DOM or DHTML old school style... but you really should ask yourself one question... why? There are so many good Ajax toolkits and frameworks that you really shouldn't concern yourself with low-level stuff like that. Additionally, truely rich internet applications (RIA) require a lot more than just basic snippets. I'm not a big fan of Gartner one way or another, but I do find thier classification levels helpful. For those who aren't familiar with them, here they are:
    1. Snippets - Enhancing existing web applications (Slashdot; other tech site that I shall not mention)
    2. Widgets - Snippets + UI Components such as Tree & Grid (IBM Online Help; Yahoo UI Widgets; Backbase)
    3. Specialized Framework - Single purpose, mostly client-side logic (Gmail; Google Maps; Yahoo Mail, Tibco GI)
    4. RIA Framework - General purpose, tightly coupled client & server side architecture (ThinWire http://www.thinwire.com/ [thinwire.com], Echo2)
    IMHO, category 1 & 2 should be used for enhancing existing applications that cannot be replaced outright. Category 3 should be reserved for those building a consumer portal that must have a totally unique look & feel, and even in that case using something lightweight like prototype should be your starting point. And category 4 frameworks should be used for all new enterprise application development.

    Check out the following to get a feel of what an RIA application is like: -Josh <G>

"When the going gets weird, the weird turn pro..." -- Hunter S. Thompson

Working...