A while back , I wrote an article for O’Reilly’s sister site , Java.net about How to add Ajax to your Struts Application. While it was pretty straightfoward (as is Ajax underneath all the hype), it still involved a little to much JavaScript for my liking. Nothing against JavaScript, but if you write it , you have to support it. Far better to use a standard Ajax library , like DWR , Prototype or Dojo.
So , along comes Struts 2. Be careful - it’s good , but a different beast under the covers from Struts 1. It does a lot of things better - for example , the way it has Actions as normal POJO’s makes it a lot of things easier to unit test.
Struts 2 also gives you Ajax ‘out of the box’. No writing of javascript, no debugging against various browsers; just configure and go. A full description of how to setup Struts 2 to use Ajax is in this wiki article. The quick version is:
1. Setup Struts 2
2. Add the Struts-Ajax URL and Div Tag.
That’s it. Ajax without the fuss.
Even better that the Struts guys have implemented the Ajax functionality using the Prototype Ajax Library, so you get the benefit of all the improvements there.
What do you think? Will you move to Struts 2 just for the new Ajax capabilities?