views:

366

answers:

5
+4  Q: 

AJAX-Framework

Which Ajax framework/toolkit can you recommend for building the GUI of web applications that are using struts?

A: 

Struts already come with Dojo framework. You can set your application theme to ajax and you will be able to use it.

Give a look at struts.ui.theme property at struts.properties file!

A good article for you to read is this one at JavaWorld

Fernando Barrocal
Careful with dojo. It's benchmarks show it's the slowest renderer of all of the popular javascript libraries.
Kieveli
A: 

I'd go with ExtJS (http://extjs.com/). It has a very good component and event model and very good support. It's AJAX at it's best ;)

You can use actions with a JSON response to provide data to the Ext frontend. You don't even need to mix you client frontend with the server frontend (via JSPX / tags).

Some see the fact that you have to develop the client frontend separated from the server frontend as a disadvantage of Ext. I think that it's not, as I have switched web applications built with Ext from a java backend to a .Net backend without changing a line of client frontend code, be it HTML or Javascript.

Have a look at the Ext examples and docs before you decide.

Bogdan
+1  A: 

I'd say that your AJAX/javascript library choice should depend less on how your backend is implemented and more on what your UI is going to be.

If your site is mostly going to be static web pages with some AJAX thrown in then it would be better to use a lighter javascript framework like jquery. But if you are creating an UI more like a web application, where the user stays at a single page for a long time (think gmail, google calendar, etc) then it probably is better to look at Dojo, ExtJs, or GWT.

timmfin
+1  A: 

I suggest JQuery's UI plugin.

jQuery, prototype, Yahoo! User Interface, MooTools, dojo, and ExtJS will have you working with very solid code. Other posibilities that I can't vouch for myself: QooxDoo

antony.trupe
Don't forget about QooxDoo! (http://qooxdoo.org)
Kieveli
Oh, and YUI! (http://developer.yahoo.com/yui)
Kieveli
A: 

It's already been mentioned, but I will say it again: jQuery. The strength of jQuery is not just the ability to make a simple AJAX call or the great UI extension library. In my humble opinion, the best part of jQuery is how you can easily handle the return data. jQuery easily allows you to navigate XML just like you can HTML.

For instance, say you get back an xml request:

(: Borrowed this XML document from a MarkLogic training file :)

<author name="Boynton">
  <book>
    <title>Barnyard Dance!</title>
    <year>1993</year>
  </book>
  <book>
    <title>Hippos Go Berserk!</title>
    <year>1996</year>
  </book>
</author>

jQuery can retrieve all the year elements with this simple command:

var years = $("year");

//Ok, lets act on each element instead

$("year").each(function(index, value){
   alert("Element " + index + " = " + value);
});

/* OUTPUT
   Element 0 = 1993
   Element 1 = 1996
/*

Try doing that in normal Javascript!

Furthermore, the way jQuery is designed is simply beautiful. The founders encourage extending the framework by adding the ability to create extensions into the core of the library (sure you can always just edit the Javascript file, but what happens when there's a critical update to the framework).

Another great reason to use jQuery is its compatibility with other Javascript frameworks. By default both Prototype and jQuery use the "$" sign to refer to the main library object. Only jQuery adds the functionality to remove this reference so it can coexist with Prototype.

jQuery makes JavaScript enjoyable.

Richard Clayton