O'Reilly logo

Ajax on Java by Steven Douglas Olson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 8. Ajax on Struts

Struts is one of the most mature and widely used Model-View-Controller (MVC) frameworks for Java web applications, so it’s natural to ask the question, “How do you add Ajax features to Struts applications?” And, as you’d expect, there are several good answers. In this chapter, we’ll investigate two approaches: using Struts-Layout, which implements some Ajax features, and using the DWR library (introduced in Chapter 6) within Struts applications.

This chapter isn’t a tutorial on or introduction to Struts. If you want to learn more about Struts, some good sources are Programming Jakarta Struts, by Chuck Cavaness, and Jakarta Struts Cookbook, by Bill Siggelkow (both published by O’Reilly). It’s also worth looking at the documentation at http://struts.apache.org.

Struts-Layout

Struts-Layout (http://struts.application-servers.com) is a custom tag library that provides a number of ready-made Struts components. The most notable for our purposes is the suggestion field. Although Struts-Layout has other tags (for panels, input fields, tables, treeviews, sortable lists, data grids, pop-ups, calendars, and more), the suggestion field is the only one that’s Ajax-enabled, and it’s such a nice implementation that it’s worth discussing. The other tags in the Struts-Layout library are worth investigating, too, but I’ll leave that up to you. Its creators claim that Struts-Layout enables you to create web pages without knowing HTML. That’s a bit extreme, but they have done ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required