Article on Using Ajax with Struts


News: Article on Using Ajax with Struts

  1. Article on Using Ajax with Struts (13 messages)

    Struts has been one of the major Java Frameworks for building Web applications for a number of years. Ajax is the latest buzz on building dynamic, user friendly web interfaces. How can Java Developers add the power of Ajax to these existing Struts Applications without having to tear out the existing code?

    Sprinkle Some AJAX Magic in Your Struts Web Application, hosted on, shows how.

    How many ServerSide readers are actually developing using Ajax? Do they feel that it is living up to the hype? Are readers inclined to extend their existing (Struts based) apps, or go for a complete rebuild using something like DWR (Direct Web Remoting), Dojo, or other such frameworks?

    Threaded Messages (13)

  2. The idea is good, but not too fresh ;)

    AjaxAnywhere, AjaxTags and probably other open source projects already do the same thing without JavaScript coding.

    Al least these two links should be present in your article to liberate your readers from unnecessary JavaScript coding.
  3. Check out this also from Coldtags suite:
  4. Thanks for suggesting AjaxAnywhere.

    In my opinion, one of the many Ajax Libraries that have sprung up will win out and become a de-facto standard, similar to what Struts was for the previous generation of Web Applications.

    The focus of the article was adding Ajax to existing applications , without having to add or replace libraries. Where you have choice of moving to new libraries, the projects like AjaxAnywyere and AjaxTags are worth taking a look at - several others , including DWR are mentioned in the article.

  5. Another option for the article[ Go to top ]

    I just started playing around with AJAX to do something similar to the example in the article. The solution I choose was not mentioned in the article and it was to have the AJAX call return the HTML for the table. That way I don't need to have any messy Javacript code to parse the response. And I reuse the same JSP logic that created the table initially. For my needs at least this approach appears to work well and I don't have the need for the other frameworks as of yet.

    btw, I was designing a treeview widget where a tree folder could be lazy-loaded.
  6. Another option for the article[ Go to top ]

    Looked at doing it that way - the difference between the two approaches is that the article can use an asynchronous call, so is more robust where there the network is not guaranteed (ie most internet and many intranets).

  7. AJAX returnnig HTML snippets[ Go to top ]

    I did a prototype like this. The AJAX call his the same Struts actions forwarding to JSPs and JSP fragments, returning the generated HTML to the XmlHttpRequest object. The client then just had to do element.innerHTML = req.responseText;

    This had the advantage that I didn't have to write rendering code once in JSP and dynamic rendering code of the same markup in JavaScript. I just write it once and use it both ways.

    However, we're now using a portal, and calling a portlet is different from calling an AJAX servlet, so reusing the same code just won't work without a lot of kludging.
  8. Ajax In Portlets[ Go to top ]

    One can also go through the following article:

  9. Silly question[ Go to top ]

    In the tutorial, After posting to the struts action, the struts action forwards to index.jsp [ view ]

    I was under the impression, the action should refresh only a part of the page using Ajax. In this the view itself is bit different.
  10. Silly question[ Go to top ]

    It's a good question.

    To keep things simple , the action forwards to the same Index.jsp to display the page. The Page , using logic tags , decides which sections needs displayed.

    It would be possible to forward to a different page as long as the <Span> tags are the same on both pages. The article mentions this (near the end), but does not go into detail.

  11. Silly question[ Go to top ]

    What is a POST back pattern right from ASP.NET
    Do we really need a Struts?

  12. Silly question[ Go to top ]

    Many people have been asking the question 'do we need Struts' for quite a long time , even though it has served the Java Community Well :-)

    Struts is a Java - Web implementation of the Model-View-Controller pattern. I wouldn't be surprised if it was close to an ASP.Net pattern, given the amount of cross-pollination between the two.

  13. The AJAX hypo is far reached[ Go to top ]

    Please read

    One has really to think about using JavaScript for non-trivial stuff.
  14. DWR and Struts?[ Go to top ]

    Has anyone used DWR to call Struts Action classes (or a thin wrapper on top of it)? We have a lot of existing Struts code and we would like to leverage it.