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.

Simplified UI Tags in Struts 2

Struts 2.0.3 contains a much needed simplification of its UI tag libraries. Before 2.0.3, you had to define a property three times (in the value, label and name attributes):

<s:textfield label="%{getText('user.firstName')}" name="user.firstName" 
    value="%{user.firstName}" cssClass="text medium"/>

In 2.0.3+, you can use the "key" attribute to replace all these attributes. For example:

<s:textfield key="user.firstName" cssClass="text medium"/>

One of the things I really like about WebWork/Struts 2 is the previous examples have the ability to write out the entire form row, rather than just an input field. Even better, the markup rendered is customizable via FreeMarker templates.

The bad news is Struts 2.0.3 never got released because the struts-annotations project hasn't had a release yet (good ol' Mavenism). The good news is Struts 2.0.4 is rumored to be out by the end of the month. In the meantime, if you're using Maven 2, you can use AppFuse's repository to get the goods. Here's the repo settings you're need:

<repositories>
    <repository>
        <id>appfuse</id>
        <name>AppFuse Repository</name>
        <url>http://static.appfuse.org/repository</url>
    </repository>
    <repository>
        <id>struts-203-staging</id>
        <name>Apache Struts 2.0.3 Staging Repository</name>
        <url>http://people.apache.org/builds/struts/2.0.3/m2-staging-repository</url>
    </repository>
</repositories>

Yeah, I could just advise you to use AppFuse 2.0 - but we're having a hard enough time supporting our existing users. ;-)

Posted in Java at Jan 23 2007, 06:02:22 PM MST 6 Comments
Comments:

Hello Matt: Can you give us your opinion about the actual WebWork 2 vs Spring MVC in a production environment? Is Spring MVC losing momentum or features with this new framework? Thanks.

Posted by Robert on January 24, 2007 at 09:22 AM MST #

Matt, What do you mean by "good ol' Mavenism"? I have been eagerly watching Maven for quite some time, but haven't had an opportunity to use it in-depth... So, I'm really interested in what weakness this comment is pointing to... Thanks!

Posted by Nelz on January 24, 2007 at 09:52 AM MST #

Robert - I believe that both Struts 2 (WebWork) and Spring MVC are excellent frameworks. In fact, WebWork powers many Java-based products: JIRA, Confluence, as well as sites like InfoQ.com. I don't know if Spring MVC is loosing momentum, but I can't help but think Struts 2 (and other action frameworks like Stripes) are positioned better to succeed.

Why? Because they have a dedicated team to develop and improving the web framework. If you ask the Spring team why Spring MVC is special, they'll likely respond that Spring Web Flow and DWR give them "Web 2.0" abilities. However, these two frameworks can be used with Struts 2 as well. I don't see Spring MVC losing momentum, I just see Struts 2 regaining the momentum that Struts 1 had.

Nelz - I've been knee deep in Maven 2 for almost a year now. The issue I'm speaking about here is probably as much of an Apache-ism as it is a Mavenism. When they did the release, the struts-annotations projects had a 1.0-SNAPSHOT version. When releasing, you shouldn't depend on an unreleased (SNAPSHOT) project.

  • Mavenism: The maven-release-plugin won't allow you to perform a release if you have snapshot dependencies.
  • Apacheism: The release won't get voted GA if you have SNAPSHOT dependencies.

Posted by Matt Raible on January 24, 2007 at 01:14 PM MST #

Regarding the "simple" textfield tag.. Haven't they always been like that (or atleast since WW 2)? I never needed anything more than a <ww:textfield name="user.name"/> for binding. Did it suddenly become an issue in the Struts 2 tag (and are there many other issues like that)?

Posted by Thomas Ferris Nicolaisen on January 24, 2007 at 01:56 PM MST #

Thomas - did you use <ww:textfield> to render the label as well? This is where the issue crops up - when you're trying to write the entire form row.

Posted by Matt Raible on January 24, 2007 at 02:03 PM MST #

Aha. We never had any correlation between property (i18n) name and field name (long story), so didn't bump into that one :)

Posted by Thomas Ferris Nicolaisen on January 24, 2007 at 02:10 PM MST #

Post a Comment:
  • HTML Syntax: Allowed