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 by Jason Carreira on October 17, 2005 at 05:19 PM MDT #
Posted by René Lavoie on October 17, 2005 at 05:37 PM MDT #
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 #
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 #
Posted by Sanjiv Jivan on October 18, 2005 at 04:53 AM MDT #
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 #
Posted by 65.34.210.171 on October 18, 2005 at 11:28 AM MDT #
Posted by Mohan Radhakrishnan on October 19, 2005 at 10:04 AM MDT #
Posted by 216.26.80.8 on October 19, 2005 at 06:55 PM MDT #
Posted by J_zealot on October 25, 2005 at 01:44 AM MDT #
Posted by Jettro Coenradie on November 06, 2005 at 08:22 PM MST #
Posted by arnold villasanta on March 23, 2007 at 02:06 AM MDT #