Struts 2

After a few years of slogging away trying to understand Spring MVC, which for me seems to be a never ending task, I started looking at Struts 2. It’s certainly an improvement over Spring MVC, that’s for sure.

Then a friend encouraged me to look at Wicket. There are a lot of web frameworks out there and I’d heard of Wicket. So I finally sat down and read through 5 Days of Wicket and I have to say, my initial impression is good. But I won’t really know until I start doing a sample application with it.

I’ve been working on a trivial sample Struts 2 application after finishing Struts 2 In Action, and there are some warts that bother me. One thing that immediately bothered me while reading the book is how in your jsp files OGNL expressions use %{variable} instead of the typical jsp ${variable}. And you often use just variable. And then sometimes you use %{'variable'}. And sometimes #variable.

As an example of how this is perplexing, one of my trivial examples starts with a page with a form and then you‘re redirected to the second page. The form data, the user‘s name and email, are passed as GET parameters on the redirect:

        <action name="userAdd">
            <result name="success" type="redirectAction">
                <param name="actionName">list</param>
                <param name="userName">%{}</param>
                <param name="userEmail">%{}</param>

But at first I used ${} and the email was correct but for the value it substituted was my workstation user name. WTF!? Yes, it’s a java system variable. But that’s the kind of stuff that drives me to drink.

There’s something about the flow between pages or actions that doesn’t seem quite right, but I can’t put my finger on it. On the one hand, they hide the machinery of the POST and GET http methods; in other words, you don’t have to concern yourself with knowing that the initial page display of a web form uses GET and when it’s submitted it uses POST. And that’s probably a good thing. But there’s still something about it that seems klunky.

Another thing that bothered me is that up until recently (the next release as it so happens) Struts 2 didn’t provide any convenient way to adequately test your action classes. In a Struts 2 web application the Action class often does only a part of the work; interceptors do the rest . When you’re testing your Action class you need a test harness to test your Action in concert with the interceptors, and that’s been missing. The next release will have a new plugin, the JUnit plugin, which addresses this. But I find it disappointing that it’s taken them this long to provide something so obviously essential.

So I’m looking forward to trying Wicket. I feel like Goldilocks and the Three Bears; I’m looking for that web framework that will make me say, “Ah, this is just right.”


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s