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.

Updated Web Tier Specs for Java EE 5

Ed Burns (JSP Spec Lead) points out there's New Drafts of Java EE Web Tier: JSF 1.2, JSP 2.1, Servlet 2.5

I'm pleased to announce another revision of the Java EE Web Tier. In Jan Luehe's blog you can find out what's new in JSP 2.1 Proposed Final Draft 2 (PFD2). The Change Log for Servlet 2.5 will give you the scoop on the Servlet spec. This blog entry will show what's new in the JSF spec.

In JSF, the most visible new feature since the last draft of the spec is the addition of the invokeOnComponent() method on UIComponent. See below for more details.

This revision of the Java Web Tier is fully implemented in glassfish build 37, Sun's open source Java EE 5 Application Server, and the basis for the upcoming Java EE SDK.

I changed the link to Jan Luehe's blog because Ed's link seems to be incorrect. My guess is Java EE will be finalized and released before JavaOne. This is how Sun usually does things: work like mad until JavaOne, then take a week or two off to celebrate the release. Other rumors I've heard are that JBoss and Geronimo hope to release Java EE 5 compliant releases by or at JavaOne.

2006 is shaping up to be quite a year for the popular Java web frameworks. Tapestry 4.0, WebWork 2.2, JSF 1.2 and Spring MVC 2.0 (with form tag libraries and smart defaults). The question is, how long will it take for MyFaces to implement JSF 1.2? And when will we see a large-scale site deployed with JSF?

Why isn't Struts or your favorite framework in this list? Struts is being replaced by WebWork and the rest simply don't have the market share. No one has heard of RIFE or Wicket. However, that didn't stop me from encouraging SourceBeat to publish a Wicket book. Having good (published) documentation about a project is the first step to corporate adoption IMO.

Posted in Java at Feb 17 2006, 11:06:34 AM MST Add a Comment

Dependency Injection with SiteMesh

Let me start off by saying I think that both SiteMesh and Tiles are great frameworks. I was a long time user and fan of Tiles, and I think it's appropriate for certain situations. However, I've been a heavy user of SiteMesh since it passed the 10 minute test. While most heavy users of SiteMesh (the Atlassian guys come to mind) say that it can do everything that Tiles can do, these features are largely undocumented. This is my attempt to document a cool feature.

In a site I recently helped develop, we needed a couple of features:

  • A tabbed menu that highlighted the current tab based on which page you were on.
  • A bunch of "panels" on the right sidebar that changed according to the page.

To make this work, we used the meta tag functionality that SiteMesh provides.

Funny side/related note, I just googled for this tag and found this howto, which is similar to this one.

In our pages, we added the meta tags to set the active menu, as well as which panels to show in the sidebar:

<head>
    <title><fmt:message key="authorList.title"/></title>
    <meta name="menu" content="Authors"/>
    <meta name="panels" content="administration,blogs,events"/>
</head>

Then, in our decorator, we interpret these separately. First, we used Struts Menu (with Velocity) for the navigation system:

<c:set var="currentMenu" scope="request">
    <decorator:getProperty property="meta.menu"/>
</c:set>
<c:import url="/WEB-INF/pages/menu.jsp">
    <c:param name="template" value="/template/menu/tabs.html"/>
</c:import>

The menu.jsp page takes "template" as a parameter so we display the same menu links using a different Velocity template (for example, links at the bottom of the page).

<menu:useMenuDisplayer name="Velocity" config="${param.template}" permissions="rolesAdapter">

Then our tabs.html Velocity template uses the "currentMenu" attribute to determine which menu to highlight.

## displayMenu is defined in WEB-INF/classes/globalMacros.vm
#macro( menuItem $menu $level )
  #set ($title = $displayer.getMessage($menu.title))
  #if ($menu.url)
    #if ($menu.name == $currentMenu)
      <span class="current">
    #end
      <a href="$!menu.url" title="$title"><span>$title</span></a>
    #if ($menu.name == $request.getAttribute('currentMenu'))
      </span>
    #end
  #end
#end

#if ($displayer.isAllowed($menu))
    #displayMenu($menu 0)
#end

As far as the panel injection goes, that's processed using the following logic in our decorator:

<c:set var="panels"><decorator:getProperty property="meta.panels"/></c:set>
<!-- No panels set, use default set of panels -->
<c:if test="${empty panels}"><c:set var="panels" value="different,partners"/></c:if>
<c:forEach var="panel" items="${panels}">
    <c:import url="/WEB-INF/pages/panels/${panel}.jsp"/>
</c:forEach>    

Since this site used WebWork, the <ww:action> tag made it easy to give each panel independence. That is, each panel could load on its own, supply its own data, and not worry about the data being prepared beforehand. Here's an example:

<%@ include file="/common/taglibs.jsp"%>

<h2>Author Blogs</h2>

<ww:action name="'authors'" id="authors" namespace="default"/>

<div class="item">
    <ww:iterator value="#authors.authors" status="index">
        <a href="<ww:property value="blog.feedUrl"/>">
            <img src="${ctxPath}/images/icons/xml.gif" alt="XML Feed" 
                style="margin-right: 5px; vertical-align: middle"/></a>
        <a href="<ww:property value="blog.url"/>"><ww:property value="name"/></a>
        <br />
    </ww:iterator>
</div>

Of course, now that you can use Tiles with WebWork, Struts, Spring MVC and JSF - you could use Tiles for the injection and SiteMesh for the decoration.

Now if we could just get someone to write a JSF Decorator for SiteMesh, like Erik Hatcher did for Tapestry.

Posted in Java at Feb 16 2006, 09:57:23 AM MST 6 Comments

How to use Tiles with WebWork

This evening, I created a TilesResult for WebWork that allows you to use Tiles with WebWork. For the following to work in your application, you'll need a nightly build of Tiles, commons-digester (which Tiles requires) and this patch for WebWork. For your convenience, I've posted a patched webwork-2.2.2.jar (with TilesResult).

I also posted a webwork-tiles.war that you can try and download yourself. It's based on Equinox, so you will need to setup PostgreSQL and an "equinox" database - or you can just change the database settings in WEB-INF/lib/jdbc.properties.

On to the instructions:

1. In your web.xml file, you need to add a servlet entry for TilesServlet to load the tiles definitions into the ServletContext.

    <servlet>
        <servlet-name>tiles</servlet-name>
        <servlet-class>org.apache.tiles.servlets.TilesServlet</servlet-class>
        <init-param>
            <param-name>definitions-config</param-name>
            <param-value>/WEB-INF/tiles-config.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

2. In xwork.xml, use type="tiles" on your <result>.

    <action name="editUser" class="userAction" method="edit">
        <result name="success" type="tiles">userForm</result>
        <result name="input" type="tiles">userList</result>
    </action>

I'm sure WebWork has a way of making this result type the default, I just haven't found it yet.

Hat tip to Spring's TilesView (source) for showing how to make this work.

Update: While I'm a happy SiteMesh user, I've recently had some clients who were more interested in Tiles. This largely inspired me to see if WebWork + Tiles was possible.

Update 2: It looks like TilesResult will be included in WebWork 2.2.2. Now if we could just get the Tiles team to cut a release.

Posted in Java at Feb 16 2006, 01:08:42 AM MST 3 Comments

Large sites powered by Java web frameworks and Tiles + WebWork

Yesterday, I delivered a Comparing Web Frameworks seminar that included Struts, Spring MVC, WebWork, JSF and Tapestry. This was for a client that's in the process of re-working an extremely high traffic site (50+ servers currently) from Servlets + JSPs to a web framework. They love the idea of Tiles (and know how to use it) as well as plan on integrating many Ajax features.

We quickly eliminated Struts because of ActionForms since they're planning on moving to persisted POJOs. Spring MVC and JSF had a notch up because they work with Tiles. However, JSF has reportedly had scalability issues. Furthermore, it's the most-complained about framework out there. One attendee noted how she was impressed with the low number of complaints about WebWork.

WebWork doesn't integrate with Tiles (but probably will soon) and they were concerned about SiteMesh performance with large pages (1MB + of text). While I believe SiteMesh can do almost everything that Tiles can do, I also agree that Tiles is a good technology. Furthermore, the "advanced features" of SiteMesh to be largely undocumented, which can be a barrier for adopting it as a "development standard".

Spring MVC was dinged because it doesn't have built-in Ajax support like WebWork and Tapestry (via Tacos). However, it's support for Tiles might just make it the one they choose - especially since they plan on using Spring in the middle-tier/backend. While they loved the idea of Tapestry, they didn't think they could afford the learning curve and I don't know enough about the @Border component to verify if it has all of Tile's functionality.

One interesting thing that came up was the list of high-volume sites using these various web frameworks. Tapestry seems to come out on top when you look at the list of well-known sites. However, I'm sure there are plenty I don't know about. If you know of high-volume sites using any of these five frameworks, please let me know. I'm looking for major sites with millions of hits per day. Here's my current list (extra points for fancy templating with SiteMesh/Tiles + Ajax widgets):

  • Struts: None that I know of off the top of my head, but I'm sure there are plenty.
  • Spring MVC: None that I know of.
  • WebWork: JavaBlogs (don't know if this exactly qualifies as high-volume, there aren't that many Java developers). WebWork also has a few products based on it (i.e. Jive, JIRA, Confluence), but these companies also employ WebWork committers.
  • JSF: None that I know of.
  • Tapestry: NHL.com, TheServerSide.com (similar comments to JavaBlogs) and Zillow.com.

Thanks!

Related: How To use Tiles like SiteMesh and SourceLab's Web application technologies comparison (with performance numbers!).

Update: FWIW, I figured out How to use Tiles with WebWork and wrote a short howto for doing dependency injection with SiteMesh.

Posted in Java at Feb 15 2006, 11:55:57 AM MST 30 Comments

Wanna learn more about Geronimo?

If you're interested in learning more about Geronimo, you might want to attend Jeff's Introduction to Apache Geronimo 1.0 Webinar. It starts at 11:00 a.m. PST today. You can register here.

Posted in Java at Feb 15 2006, 10:40:27 AM MST Add a Comment

DisplayTag 1.1 Released!

Read the release notes, change log, migration instructions and download. Don't forget to check out the live demo too. If you're using Maven 2, you simply need to add a new repository:

  <repositories>
    <repository>
      <id>displaytag</id>
      <url>http://displaytag.sourceforge.net/m2repo</url>
    </repository>
  </repositories>
  ...
    <dependency>
      <groupId>displaytag</groupId>
      <artifactId>displaytag</artifactId>
      <version>1.1</version>
      <scope>runtime</scope>
    </dependency>

This release is pretty huge IMO. You can now do external sorting and paging, which should eliminate any performance concerns with using this library. Another nice feature is portlet support. Nice work Fabrizio!

Update: This release is now at ibiblio, so you don't need to add the custom repository to your pom.xml anymore.

Posted in Java at Feb 12 2006, 12:26:15 PM MST 10 Comments

Weekend Update

Yikes! I can't believe it's been a whole week since I last blogged. Actually, with my workload it's not that surprising. Don't let anyone ever tell you that working for an open source consulting and support company is easy. When we started, we dreamed of working a couple of weeks a month, and working on open source the rest of the time. Business has really started to pick up in 2006, so that dream is quickly fading. Regardless, this week was a good one.

I managed to get Equinox upgraded to Tapestry 4.0 and WebWork 2.2. Both of these releases are much nicer than their predecessors and I plan to do a write-up next week. I especially dig how WebWork 2.2 allows you to do a popup calendar with less code than both JSF or Tapestry. It really is a kick-ass web framework and only getting better.

Virtuas Other than that, I had some fun with Maven 2 - converting all the Spring Fundamentals labs to use it. The invalid-POM situation continues to be atrocious and shows no sign of improving soon. I really like the idea of the Jetty 6 Maven Plugin, but unfortunately, it doesn't seem to play nice with SiteMesh. Lastly, I had some fun getting JOTM to work on Tomcat 5.5.x. All in all, I learned a lot this week, just didn't have much time to write about it.

AppFuseIn AppFuse News, Mika Göckel wrote tutorial on integrating XFire with AppFuse. Mika also authored a tutorial on AppFuse + Axis. He obviously knows his way around AppFuse - so we nominated and accepted him as a committer. Welcome aboard Mika! Finally, Brian Topping has converted a version of AppFuse to Maven 2. With any luck, AppFuse will be an archetype that you can install from Maven someday.

I'm flying out to San Francisco for a 1-day seminar next week and my MacBook Pro couldn't arrive any sooner (12 days and counting).

Posted in Java at Feb 11 2006, 06:22:03 PM MST 5 Comments

EMMA vs. Cobertura for Code Coverage

I'm looking to add code-coverage reporting to AppFuse. The two open source libraries I know of to do this are EMMA (CPL) and Cobertura (ASL). Which one is the better library to use? Both projects seem to be actively developed - and there are AppFuse HowTos for both, so the decision making process is a bit difficult.

Any insights into why one tool (or project) is better than the other is appreciated.

Posted in Java at Feb 03 2006, 05:16:35 PM MST 13 Comments

Want to be more productive with IDEA?

If you want to be more productive with IDEA, Patrick Lightbody has a good suggestion in IDEA Live Templates: more powerful than you think. Now where's the list of the built-in live templates? Does Eclipse have a similar feature?

Posted in Java at Feb 01 2006, 02:45:15 PM MST 4 Comments

CMS Evaluation Summary

I got an interesting comment on one of my blog posts recently.

Matt, I'd be curious to hear why Virtuas is using Drupal and not the same Java stack they advertise on their home page (i.e. one or more of Geronimo/Tomcat/Spring/Hibernate/MyFaces/JBoss). I realize the standard answer is "because Java is for heavyweight sites and PHP is the right tool for the job" but I'm wondering if there was more to the decision that just that.

My Reply:

The reason we chose Drupal was from an evaluation that I did - where I compared a number of open source CMS solutions:

Drupal was simply the best tool for the job when we were looking for a solution.

Posted in Java at Jan 30 2006, 01:30:42 PM MST Add a Comment