Matt RaibleMatt Raible is a Web Developer and Java Champion. Connect with him on LinkedIn.

The Angular Mini-Book The Angular Mini-Book is a guide to getting started with Angular. You'll learn how to develop a bare-bones application, test it, and deploy it. Then you'll move on to adding Bootstrap, Angular Material, continuous integration, and authentication.

Spring Boot is a popular framework for building REST APIs. You'll learn how to integrate Angular with Spring Boot and use security best practices like HTTPS and a content security policy.

For book updates, follow @angular_book on Twitter.

The JHipster Mini-Book The JHipster Mini-Book is a guide to getting started with hip technologies today: Angular, Bootstrap, and Spring Boot. All of these frameworks are wrapped up in an easy-to-use project called JHipster.

This book shows you how to build an app with JHipster, and guides you through the plethora of tools, techniques and options you can use. Furthermore, it explains the UI and API building blocks so you understand the underpinnings of your great application.

For book updates, follow @jhipster-book on Twitter.

10+ YEARS


Over 10 years ago, I wrote my first blog post. Since then, I've authored books, had kids, traveled the world, found Trish and blogged about it all.

What's the best way to integrate Ajax into a Java webapp?

I received an e-mail over the weekend asking how to integrating Ajax into into the various web frameworks covered in my Java Web Framework Comparison Whitepaper. Below is my reply:

The best thing that I've seen is to use DWR, Prototype and Scriptaculous.
These will work with all web frameworks, and if you're using Spring on the backend -
DWR makes it easy to expose your beans as JavaScript objects.

Also, there's a number of tag library solutions that greatly simplify things:

  http://javawebparts.sf.net
  http://ajaxanywhere.sf.net
  http://ajaxtags.sf.net

I haven't used the first one, but I have used AjaxAnywhere and saw a demo of
AjaxTags from its developers.  They both look like they could be very useful.

For those of you using Ajax in your Java webapps - what's your advice? Do you use these same libraries or other ones?

This post was partially motivated by my desire to reiterate things that are so obvious. ;-)

Posted in Java at Oct 17 2005, 10:50:00 AM MDT 12 Comments
Comments:

Well, the easiest way is to try out our (still beta) WebWork 2.2 with our Ajax theme for the UI tags. It lets you very easily wire together Ajax events in your web pages without having to know much (or any) Javascript.

Posted by Jason Carreira on October 17, 2005 at 05:19 PM MDT #

I m surprise you dont mention mochikit and Dojo given the recommended read from last week ... Comparing Ajax Frameworks: From the SpikeSource blog I havent tried either yet, but the arguments against Prototype caught my eye ... "Prototype did ugly things that aren't compatible with (most) other JavaScript libraries and had no documentation or tests"

Posted by René Lavoie on October 17, 2005 at 05:37 PM MDT #

I'm totally sold by the component frameworks approach to this. Both Tapestry and Wicket support "out of the box" ajax components that handle all the javascript internally. At the end of the day, Java developers should write Java (not javascript).

Wicket, in particular, has some *wicked* ajax components starting to show up that are extremely easy to use without worrying about the javascript implementation.

Posted by Ryan Sonnek on October 17, 2005 at 05:39 PM MDT #

Let me start by saying that I have just recently 'returned' to web application development. For the last 5 years or so, I have been developing J2EE apps (stateless session beans, RMI, etc.) with Swing clients.

I was getting pretty frustrated trying to decide on the web framework to base my new development efforts until I found Wicket. If you are used to component based development, I think this is the best framework. It keeps the html templates what they should be - html, without adding a bunch of XML declaration files.

Wicket 1.1 rc2 and Scriptaculous combine to add seamless AJAX support. It's pretty darn easy and slick.

One of the main design issues for me was dealing with lookup functionality, ie. a field that needs to be validated against another database table. I was struggling with the best way to handle this from a page flow perspective. To me, this is a perfect fit for using the autocomplete text field, like Google Suggest. I now have lookup type functionality in all my web pages using AJAX. It looks and performs well and solves the web page navigation issue of handling lookups. And I didn't have to write a bit of javascript code in my html templates!

Posted by Brent Roberts on October 17, 2005 at 10:24 PM MDT #

I've been using AjaxAnywhere and really like it. The concept is really neat and its appeal lies in its simplicity. It is very easy to incorporate in any *web* applicaiton without a complete overhaul of the existing architecture. Although its message seems to be to "ajaxify existing projects", I see it as a practical and powerful library for new projects as well. I beleive that a big advantage of AJAX is just the perception of smooth transition across user actions even if the actual response time is the same as a tradional request-response based web app.

Posted by Sanjiv Jivan on October 18, 2005 at 04:53 AM MDT #

I've got to tell you about Zimbra! This is world-class Ajax, but it's not for the faint of heart. This is Ajax-based apps vs Ajax-enhanced web apps. BIG DIFFERENCE.

Seems to me this technology is really turning Webapps on their ear, but it's not PC within the Java server community.. because it's based on Javascript. Ever read crockford on javascript? ( crockford.com, "Javascript, the worlds most misunderstood programming language.") Good read. Most java programmers will change their tune once they read "Ajax In Action" by Crane, and Crockford.

Zimbra is based on these ideas of Ajax-based web applications. Full widget sets that are entirely based on "cononical" JS implementations that abstract the cross-browser issues involved. No more browser issues, just straight ahead client-side programming!

This starts moving much of MVC to the client; it's a leapfrog effect seems to me. JSP's and Struts take a back seat to clients that only need serialized JSON objects sent to them from the server. And anyone starting a traditional struts style site these days will arrive DOA... unless they are going to dismiss Ajax as unimportant long term. A site like Zimbra does not need MVC on the server; it only needs a few JSPs to deliver the entire client AS A PAYLOAD.

In this case, what makes a good server architecture? How thin is in, on the server? Toss the controller servlet, that seems pretty obvious. Move to a client-based controller and an SOA-based server that keeps the client updated with data feeds. DWR, SOAP, REST, whatever you want.

I'm intrigued by the DWR thing.. I love the idea of just calling the java classes directly from the client. JSON works real well with this.

Can I put the MVC on the client, keep my master model on the server, and use DWR for the communications link between the two. The client models only that which the user is interested in for a given session.

"Ajax In Action" comes out this month and deals with the MVC on the client issues. It's available now on PDF download. GREAT BOOK!

Note, Isomorphic has been doing MVC on the client for some years...

And of course, Ross (Zimbra Eng VP) was once a Javasoft leader, so they are Ajax opensource trend setters with very big VC funding, releasing their code for free.. They are using Xforms in Zimbra too. This seems really exponential in my mind; like using UML to design forms. Way beyond Struts action forms.

Have a look; the Zimbra hosted demo is well worth spending time with if you want to see the ultimate Ajax application in action.

Posted by Jeff Papineau on October 18, 2005 at 05:31 AM MDT #

You take a look at Zibra and the first thing you say is: WOW! The second is: I do not want to be the person supporting it! Unless you have full control over what browser (and browser settings) have your users that is not a good idea Jeff. We have already gone through this several times but it seams that we need one more time. I look at AJAX at a way to improve user experience not as a replacement for server side MVC. By the way, AjaxTags has just released version 1.1 http://ajaxtags.sourceforge.net.

Posted by 65.34.210.171 on October 18, 2005 at 11:28 AM MDT #

I am really want to read you JIA presentation about frameworks. Where is it ? Thanks, Mohan

Posted by Mohan Radhakrishnan on October 19, 2005 at 10:04 AM MDT #

https://equinox.dev.java.net/servlets/ProjectDocumentList?folderID=4223&expandFolder=4223&folderID=2867 But it does not include the part where Matt asked how may people in the audience where using JSF. Only 4 (of around 80) raised their hands and that include Kito :-)

Posted by 216.26.80.8 on October 19, 2005 at 06:55 PM MDT #

Swato has released a beta version and a online demo at http://swato.throughworks.com With the help of this framework, you just need to register your Java class (Model) at Spring. And do all of your View/Control via JavaScript. Swato provide a OO paradigm at client side so that you just need to write the least lines of JavaScript Code. I supposed that it is the easier way to integrate it with Appfuse. Without any MVC framework at serverside.

Posted by J_zealot on October 25, 2005 at 01:44 AM MDT #

This week-end I bought the book Foundations of ajax. The writers of this book have their own framework called taconite. I think it is a very nice framework, documentation is oke, maybe the functionality is not the wide yet. But as they say themselves, they want to cover the basics and make it easy to create additions yourself. I did not have a good look at other libraries or frameworks, for now I like taconite and I think it is worth a look for you as well. http://taconite.sf.net

Posted by Jettro Coenradie on November 06, 2005 at 08:22 PM MST #

Jeff's comment was lengthy but well said. There are a couple of things which MVC in client side is more favorable than implementing the whole application in a back-end MVC framework. Users now a day demand web-apps to ?act? more likely of a desk-top application, more of an RIA. They don?t want to experience the waiting time experienced in struts/spring framework, even for just a couple of data to be fetched from the back-end and re-draw the page. Complex user interface that sometimes draw complex user interaction must be managed somehow in the client side. Having an MVC in the client is a very good option... Gone are the days of hardware restrictions in the client side. Javascript misnomers are also disregarded nowadays. Why not give Zimbra a credit for their effort? If the application is intended for a group of users, like corporate/portal apps, then take Zimbra as an option. No single AJAX framework stands tall above all others. Cheers and thank you guys for all the insights.

Posted by arnold villasanta on March 23, 2007 at 02:06 AM MDT #

Post a Comment:
  • HTML Syntax: Allowed