Rodrigo Uchôa's Java Blog

Post navigation

I’ve been working on some projects that thankfully use Apache Wicket for the presentation layer. It naturally occurred to me how Java’s 8 lambda expressions fit perfectly with Wicket. And not just me, the Wicket team seems to be already working on changing the API to provide support for lambdas out of the box.

This time I’ve chosen a common task that most of the time, in my opinion, is done the wrong way: sending e-mails. Not that people can’t figure out how e-mail APIs work, such as JavaMail or Apache’s commons-email. What I usually see as a problem is that they underestimate the need to make the sending mail routine asynchronous, and that it also should only run when the underlying transaction commits successfully (most of the time).

Although the title emphasises the word validation, this article is actually about the JSF life cycle. That’s because I believe that one of the easiest ways to truly understand the life cycle is by making something we do all the time: validating user input.

For this post I’m gonna show how to implement a “Generic DAO” class. It’s something junior developers struggle with, and usually end up writing lots of “DAO” classes doing the exact same thing. A “Generic DAO” is a convenient way to have a single class (or component one might say) responsible for persistent operations in any entity in your code. This is what I mean:

After a few months away I decided to come back in style :). I noticed that one of my previous posts about the new Date/Time API got really popular, so this time I’m going to dedicate this post to another new feature of Java 8: Lambda Expressions.