GoogleCode-a-Go-Go

I’m now the proud caretaker of two different Google Code projects.

Anvil is a business logic framework based on the context and chain of command patterns. The Anvil core is a port of the Jakarta Commons Chain of Responsibility, used by Struts 1.3. It’s available for C# now. We use Spring.NET for the object factory, and iBATIS.NET for data access (so this would be an easy port back to Java). Anvil is still way under-documented, but it works well for us. Best of all, Anvil made the transition to Ajax without missing a beat.

When we created Anvil, our original goal was to keep as much code as possible out of the ASPX pages and code-behinds, including validation and formatting. As it turns out, that same goal makes the framework an ideal backend to Ajax pages.

The other new project is Apache Struts from Square One, which hosts materials used by my training course including slide presentations, coding exercises, and a companion textbook. The text is new, but the slides and other materials have been available at the Struts University site for some time.

The course is something I’ve been creating through successive refinement. When Struts first came out, people asked me to come in for “Train the Trainer” sessions, where consultants wanted to learn Struts so they could teach it to their clients and other consultants. Then, it was direct requests from development teams who wanted to jumpstart a new project using Struts. By the time Struts 1.2 came around, people were asking me to come in and review what they’ve been doing in Struts, to see if they were on the right track.

On each trip, I’d create a new session or improve an old session, and eventually it all evolved into a course based on the Struts MailReader application. The course has now made the jump to Struts 2, and I’m working on a companion text to the original training materials, which I might offer through LuLu when it’s “ready for primetime”.

An early and incomplete draft of Part 1 of the book (‘Carpe Diem’) is available for download. The complete set of slides and other materials are available through the Struts University site. There’s even a new Google Group for questions and feedback.

Of course, although the text is a work in progress, the live course is complete, and I’ve presented it several times. Drop by Struts Mentor for more about the live course.

Many thanks to the Google Code ninjas who are making project hosting possible for grunts like me. There are rough edges still, but I can see where Google Code is going, and I’m happy to tag along for the ride.

Struts 2.0.6 Voted Ready for Primetime

I may be late to the dance, but, let me cut in and whisper in your ear: “Struts 2.0.6 is General Availability.” How’s that for a sweet something?

The GA vote went down just over a week ago, on 22 February 2007. In retrospect, the Struts 2.0.1 release was also ready for primetime. Many people have been joyfully using 2.0.1 in production since September. The holdup was that our major dependency, XWork 2, stubbornly clung to beta status from September to January. The actual code was fine, but the XWork committers wanted to spruce up the documentation and did not want to stamp the distribution “final” yet. Since then, the XWork group has changed to a milestone release system, as Struts uses. Now, we can grade both Struts and XWork releases based on experience rather than expectation.

Whilst XWork 2 twiddled with documentation, Struts 2 did not stand still. Struts 2.0.6 boasts several new heavyweight features, like plugins and a zero-configuration approach (Yes, Virginia, there is no XML!). We even moved the internal dependency injection over to Crazy Bob Lee’s new secret project, Google Guice.

Of course, by “we”, I mean our star committer Don Brown. We were going to hold off on some of these changes until after our first GA, but as an expectant father, Don was worried that the bundle of joy would cut into his committing time. So, Don managed to put aside his Nintendo Wii long enough to commit a stunning array of new features. For more about the many joyful features of Struts 2.0.6, pop by the Apache Struts website.

But, wait, there’s more! The Struts 2.0.7 release might be available next week. No earthshaking new features, just the usual successive refinements and odd code fix. Of course, it will be a drop-in binary replacement for Struts 2.0.6, so there’s no reason to wait!

For Struts 2.1.x, we planning to migrate both the portlet support and the Ajax/Dojo tags to plugins. Since we’re now using the Yahoo User Interface Library (YUI) at work, I’m also thinking we might be able to offer a Ajax/YUI plugin too. But, that’s another post. :)

Meanwhile, Struts 1.3.x is ramping up for another release, and there’s continued talk of a Struts 1.4. Test builds for Struts 1.3.7 are available, and a 1.3.8 build should follow on its heels to correct an oversight with Action redirects.

As always, the best is yet to come!

Java Web Frameworks - Simplified!

Is there a standard Java web framework?

Yes. Sun has added JavaServer Faces to its
Java Enterprise Edition, which includes other goodies like JavaServer Pages and the JavaServer Pages Standard Tag Library. If you grab the distribution that bundles the NetBeans IDE, Java has finally become a one-stop shop!

Is JSF a specification, like JSP and JSTL?

Yes. Sun provides its own Reference Implementation, but other people can provide their own implementation of the specification.

Is anyone doing that?

Yes. The Apache Software Foundation offers the Apache MyFaces JSF implementation that you can use instead of the Sun RI. Along with a certified JSF implementation, the MyFaces project also offers a number of additional JSF components. Standard JSF components include gizmos like a DataGrid. Additional components include goodies like tabbed panels, various tree views, HTML editors, scrollers, and such, that you can drop into your application. If you are just getting started with JSF, the MyFaces mailing list provides a lot of friendly, free support.

Are there other JSF component libraries available?

Yes. For example, Oracle offers ADF. In fact, Oracle donated the better part of its ADF component library to the ASF some time ago. It’s slowly becoming part of MyFaces under the name Trinidad.

What about AJAX?

People are trying various approaches toward integrating AJAX with JSF components. Some AJAX frameworks for JSF are already available, including Ajax4jsf. Generally, you can use AJAX frameworks with the Sun RI or MyFaces, as you prefer.

This is the same sort of approach that Microsoft is taking for its ASP.NET framework (which is similar to JSF). To leverage AJAX, Microsoft is building a second framework, Atlas, on top of ASP.NET.

Are there other JSF frameworks?

Yes. The Apache Shale framework extends JSF to add advanced features, many of which are designed to woo Java web developers used to Action-based frameworks, like Struts.

What’s happening with Struts?

By any measure, Apache Struts is still the most popular Java web framework. Last year, Struts merged with another web development community, WebWork, to create a new version of Struts. Apache Struts 2 is in beta release now.

Are there any comparisons of the JSF and Struts 2 feature sets?

In practice, comparing JSF and Struts 2 is less about the features and more about the development paradigms. The reason we have these two frameworks is because each solution approaches the web development problem from a different perspective.

The implicit goal of JSF-style component-based development is to make web development more like conventional desktop/GUI development. The implicit goal of Action-based development is to streamline web development and make the best of the web platform. If a team likes the idea of creating web applications as if they were desktop applications, then platforms like JSF and ASP.NET are the way to go. If a team is ready to embrace the web for what it is, then platforms like Struts, Ruby, PHP, and so forth, are still the way to go.

In other words, it all depends on the problem we are trying to solve. If the problem is that web development is unlike conventional GUI development, then the component model is a valid solution. If the problem is that web development lacks an elegant and extensible infrastructure, then the action model is a valid solution.

But can’t we create a framework that resembles GUI development but provides a simple, web-savy infrastructure?

Possibly, but that would be the web equivalent of unified field theory. Today, in physics, and in web development, we have two models that are each used for different reasons, but, side by side, the two are wildly incompatible.

In physics, it boils down to “little” or “big”? In web development, it boils down to “GUI Desktop” or “Enterprise Web”?

Pick your poison!

Free (as in beer) Microstuff

Inch by inch, step by step, Redmond softly pads closer and closer …

Earlier this year, Microsoft leapt into the free zone by making free downloads of its Express line a permanent fixture. Originally, the Express line was being positioned as low cost, but now the cost is reduced to a free download and eventual registration.

To an extent, the Express line can trace its roots to Matrix, a free ASP.NET IDE that the Microsoft team cobbled up as scaffolding for Visual Studio .NET. Afterwards, some team members lobbied to make Matrix pubically available, and it was posted on ASP.NET, along with the “starter kits” and other goodies. Matrix is interesting, but it shuns code-behinds in favor of embedding scripts into the pages.

Though, Express ain’t Matrix. Express is the real deal. Express is Visual Studio broken out as a set of point-applications, each focused on a specific part of the development process. If you are working on a n-tier application, then the Visual Studio suite is still the way to go. (Especially if you want to use plugins
like Ankh and Resharper.) But, if you are working on a simple Windows or web application, then Express may be just the thing.

All together there are six products in the Visual Express line.

  • Web Developer Express
  • SQL Server Express
  • Visual Basic Express
  • Visual C# Express
  • Visual C++ Express
  • Visual J# Express
    All permanently free for the download.

A linchpin offering is SQL Express. Unlike its MSDE predecessor, SQL Express is not performance throttled. You can use it as a production database.

For ASP.NET web developers, this changes everything. In my experience with VS 2003, you can’t really get the full benefit of the platform without using SQL Server. Of course, that’s part of the plot, but, in for a penny, in for a pound. If I’m going to use a platform, I’m going to use it best I can.

Of course, back in the VS 2003 days, using SQL Server was a budget item, so it wasn’t something everyone could do. (My team included.) Today, SQL Server Express
fits everyone’s budget: free!

I’ve been working with an Oracle shop, but being renegades, we’ve been using MySQL, so that we could develop on the desktop. But, we’ve been careful to keep it all ANSI, just in case we ever have to migrate.

It’s looking like that day is now coming, but instead of migrating to Oracle, we may be migrating to SQL Server Express!

Of course, switching database systems is, as they say, “non-trivial”. But, as it happens, we are getting ready to roll out a new version of the database schema, with a new release of the application to match, and moving from MySQL 4 to MySQL 5 in the process. At this time, it would be just as easy, even easier, for us to move to SQL Express instead.

For backup, we’ve been grabbing MySQL dumps, which are designed to reconstruct the database from scratch using SQL statements. I’ve found that by adjusting the MySQLDump parameters (mysqldump [database] –skip-opts –compatible=ansi), we can get a decent SQL Server compatible dump. We just need to make a few minor tweaks to the create table DDLs, and it’s good to go.

Just as a spike, we boosted a couple of tables into SQL Express, changed the iBATIS provider, and ran some of our unit tests. So far, all signals are green!

Of course, we don’t plan to sell our souls to the dark side. Our data access layer relies on iBATIS and a coarsely-grained data transfer object. It’s flexible and easy to test, and we won’t be changing that any time soon.

Though, in ASP.NET 2, Microsoft is giving a nod to business objects. In fact, I was impressed by the number of good practices demonstrated in the
Developing ASP.NET 2.0 Applications using AJAX video. For example, along with business objects, Scott Guthrie relied exclusively on CSS for formatting.

Toss in a some actual unit tests, and we could almost call the demo Agile. But, I’m guessing we might have to wait for ASP.NET 4 or 5 before we catch Scott writing his own unit tests :)

Struts 2.0.0 Available

We started rolling snapshots in August, and the time for tagged builds has arrived. The distribution still have some rough edges, but it is feature complete, and ready to take on eager early adopters.

The API is essentially WebWork 2.2 with some deprecations and legacy features removed. New features include wildcard mappings, JSF support, and stateful checkboxes.

We adopted the notion of wildcards from Cocoon and introduced the feature in Struts 1.3. With wildcards, we can define a action name pattern, like “Edit“ and have it match any incoming URIs that being with “Edit”. Or, if you prefer, “Edit” to match URI names ending it Edit. Or, perhaps “/“ to match names like “People/edit”.

The latter pattern, “/“ is a useful way to handle “dispatch” actions. S2 includes a mapping attribute for the method name, making it easy to setup a pattern like “method={2}” “class=actions.{1}”. Given “People/edit”, the action mapping would expand to “method=edit” “class=actions.People”. In other words, call the edit method on the People Action.

The JSF support is still new, but it looks sound. Essentially, you can use JSF components as another type of view. Of course, the view is only one part of JSF, but it’s the part that interest people first.

Checkboxes have always been a thorn in the side of web developers. If the checkbox is clear, the client submits nothing back. Nada. Zilch. It’s like the checkbox was not even there. The problem being that HTTP, being text-based, has no clear way to say “FALSE”. Struts 2 fixes this glitch by keeping track of when a checkbox is used on a page. If the checkbox control doesn’t post back, then the framework inserts a false value into the context, and, suddenly, even checkboxes are stateful. (That only took six years!)

But the sparkle on Struts 2.0.0 has to be the distribution itself. The “all” distribution weighs int 40mb, but it includes ready-to-deploy WARs of the example application, binary dependencies, source code, Java 4 compatabilility JARS, and the new and improved documentation.

The WebWork 2.2 documentation is actually quite good, and given a fresh coat of paint, the Struts 2.0 documentation almost glistens. The docs are now organized into three main parts: Tutorials, Guides, and FAQs. The Tutorials are designed to get people up and running. The Guides provide the detailed information people need as applications are created and improved, and the FAQs fill in any gaps.

If you are looking for the Next Big Thing in action-based frameworks, take Apache Struts 2.0.0 for a spin. You won’t be disappointed.