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.

How do we bake Ajax into Struts and Spring MVC?

I see a trend happening here. The next version of WebWork, as well as Tapestry and JSF are all embracing Ajax technologies. By "embracing", I mean they're not only using them, but they're making it easier for us to use them.

After using XmlHttpRequest in my last two projects, I think this is a must for Struts and Spring MVC as well. The technology is very cool and customers absolutely love it.

The question is how do we bake it in? WebWork makes it easy because its tag libraries are backed by customizable Velocity templates. With Struts and Spring MVC, it seems the best way would be to use tag libraries, but maybe there's better alternatives. Do they each need an AjaxAction/AjaxController or something that allows DWR-type stuff?

What are your thoughts? You might argue that using DWR should suffice, but w/ everyone else (even Rails) baking it into the framework - I see no reason why Spring MVC and Struts shouldn't do the same. You are using these frameworks to develop kick-ass UIs aren't you?

Posted in Java at Apr 15 2005, 06:20:28 AM MDT 13 Comments
Comments:

Actually, for Struts, someone has already created an AJAX version of the HTML taglibs. Also, Struts Flow has built-in support for AJAX (although that is AJAX with JSON instead of XML), which is very natural since Javascript is at both ends of the communication (the client-side js calls the flow script which is also js). With Struts Flow, the AJAX calls can even participate in continuations. See http://struts.apache.org/flow/remote-example.html for an example, and http://struts.apache.org/flow/templates-example.html for an example that also uses Javascript Templates for rendering HTML on both sides.

Posted by Don Brown on April 15, 2005 at 09:32 AM MDT #

To add to your wiki (Ajax):
  • 1. For Struts: XHRStruts - a very nice and detailed article too.
  • 2. For JSPs: Japano - it looks nice and complete.

Ahmed.

Posted by Ahmed Mohombe on April 15, 2005 at 09:34 AM MDT #

One thing I worry about is that while users want this technology they want a conflicting thing as well.. they want their back buttons to work properly.

At my company, we just finished up a project using invisible iframes to do a similar technique (we used the invisible iframes because we need to work on browsers that don't support XmlHttpRequest _sigh_). We did alot of work to make it so that the user can move between various modes in our control and everything works great.

Until we did a focus group study and users started to hit the back button. And when they didn't go back to the previous mode (instead it went back to the previous page), they pretty much freaked out. We have some thoughts on how to fix this but it turns out to be a rearchitecture of our framework for doing AJAX style interaction.
Has anyone else run into this? I am not sure sure how to reconcile the demands of users who don't want page refreshes but want to keep the functionality of the back button.

Maybe some of these AJAX implementations for the various web frameworks could take this into consideration. Any thoughts?

--> John

Posted by John Townsend on April 16, 2005 at 09:00 AM MDT #

In my opinion, unless Spring adds AJAX support soon, it's going to turn into the enterprise framework for large companies and Rails is going to turn into the framework that the other 95% of the world should be using (one could argue this is already the case). It really just isn't the issue with AJAX, it's the broader sense of how quickly can they adapt to what developers want and I think Rails is doing a better job of that.

Posted by PJ Hyett on April 16, 2005 at 03:42 PM MDT #

@ John:
For the back button problem, one partial solution is to open the webapplication in a window without a button bar. This way the user knows that he is in a "webapplication" and not a normal web page(this is something that every user can learn). The most of the users use the "back" button, and not the shorcut key, so it will prevent such problems if the button bar is not shown. This is used by a lot of online banking of online trading applications. The only problem is not to forget to offer a clear an precise navigation (navigation bar and menus), cause the user can't use the back button anymore.
In other applications a "fake button bar" is a good solution too. The users gets after login a window without a button bar, but instead, a customized simulation of a button bar, even with application specific actions, and of course with back and forward buttons, but with server side implementation, so that back and forward make sense from a server point of view. It takes a little to implement such a thing, but it's a very good solution and reusable in may projects. Unfortunately I found no open source project that does this, only "in house" commercial solutions.

Ahmed.

Posted by Ahmed Mohombe on April 16, 2005 at 04:19 PM MDT #

Re: "No back button" - I think that is a mistake. Applications that run in web browsers should respect the environment, not try to morph it into a pseudo-native feel. Nothing does more to confuse a user than an application that does not seamlessly support forward, back, & bookmarking.

Did we all forget why frames suck?

just my .02

Posted by Alonso on April 16, 2005 at 09:11 PM MDT #

Alonso, I absolutely agree. BTW: This is also the one objection I have regarding AJAX. For example the Echo Web framwork, completely ignores back buttons and bookmarks.

Posted by Stefan Kleineikenscheidt on April 17, 2005 at 05:02 AM MDT #

The problem with opening a window is that most users don't want that experience either. They want something that looks like an app, walks like an app, and then they want their normal web usage patterns to work. That's a tough order. Things like google maps work because they don't want multiple pages and they are a self-contained destination. That works pretty well. But when you use AJAX in something like a component with a larger app, you could be running into problems that the AJAX solutions don't solve yet. Hopefully those in the AJAX world are thinking about this when putting their frameworks together.

Posted by John Townsend on April 17, 2005 at 08:58 AM MDT #

Re: No Back Button GMail doesn't work with the back button, not does Google Maps. I think it is possible to make the back button work with AJAX apps. You just need to think about when the user wants to use it and when they don't care. Typically when the user changes views (eg reads an email in GMail) they use the back button to go back, but they don't when they are doing actions on that view (expanding and email thread for instance). If the page url changed on every "user view" change then the back button would work. GMail doesn't do this (which is mildly annoying on the witch between "View Inbox" and "Read Mail"), but Google Maps does (try typing a new address - you can navigate back to the old one using the back button).

Posted by Nick Lothian on April 17, 2005 at 05:27 PM MDT #

Marc Logemann has a post and sample of a new DWR creator for Spring on his blog:

Posted by Greg Ludington on April 18, 2005 at 11:17 AM MDT #

[Trackback] AJAX maybe a solution for those who want to improve the browsing experience, yet the existing version of Struts is not designed to incorporate with such flows, programmers have to spend tremendous efforts in exchange for an interface enhancement.

Posted by Guide Through the Dark on April 19, 2005 at 02:33 AM MDT #

A little late to this thread, but I think that adding AJAX support to Spring is very important. I've been playing around with JSON-RPC and I have to say it is very straight forward and easy to use. But it needs work to allow it to integrate into existing MVC frameworks. Having controllers for the main HTML and then something else entirely for the AJAX portion is not a good thing. I have not looked at it very hard yet, but seems like adding AJAX to Spring would be much easier than trying to shoehorn AJAX into Struts. I might be wrong though. It will be interesting to read through the earlier links.

Posted by Mark Womack on April 26, 2005 at 03:41 PM MDT #

a very simple example for implementing AJAX with Struts is at http://ajaxandstruts.blogspot.com

Posted by amalraj on December 02, 2005 at 08:02 AM MST #

Post a Comment:
Comments are closed for this entry.