December 31st, 2008 by Lincoln Baxter III

PrettyFaces 1.2.0 Released

A new major release of the PrettyFaces JSF extension for Bookmarkable/Pretty URLs is now available for download.
December 8th, 2008 by Lincoln Baxter III

PrettyFaces 1.1.0 Released

A new release of the PrettyFaces JSF extension for Bookmarkable/Pretty URLs is now availible for download. This release includes several new features.
November 12th, 2008 by Lincoln Baxter III

Make JSF intuitive, with bookmarkable and pretty URLs

What makes Pretty URLs in JSF so hard, and so slow?

Speed up development, reduce bandwidth, enhance user experience. This article gives a brief overview of JSF navigation, some of the problems, and potentially how to solve them by enabling bookmarkable, pretty URLs. Put simply… in my view, out of the box, JSF is a web framework designed for web-applications, not designed for web-sites. PrettyFaces addresses most of these issues.

Target audience for this article:

  1. The reader is familiar with JSF navigation.
  2. The reader is attempting to create a JSF app with bookmarkable “pretty” URLs. E.g.: …/mysite/archives/2008/11/11/
  3. The reader is familiar with HTTP request/response at a basic level.
October 16th, 2008 by Derek Hollis

Acegi/Spring Security JSF Integration Project continued

We’ve gotten a good number of comments from Lincoln’s latest post on Spring Security and JSF.  A few comments have asked for further code samples on how to get this example working. We created a runnable project for this example, and it can be downloaded here.
October 9th, 2008 by Lincoln Baxter III

Acegi/Spring Security Integration – JSF Login Page

Tutorials – What a nightmare

Everyone seems to be going through hell to get a fully functional JSF login page working with Spring Security (formerly Acegi,) and yes, I did too, but there’s an EASY way to make this happen. And get this:
  • It takes just five clear and well written lines of Java code.
First, the solution. Afterwards, the dirty details. (Spring 2.5.2 was used for this example, but this documentation is still relevant for Spring 3.x) You can find a downloadable working example here. There is also a followup article on post-authentication redirecting, here.
September 18th, 2008 by Lincoln Baxter III

Persist and pass FacesMessages over multiple page redirects

Very Simple

In a JSF Reference Implementation, passing global faces messages between pages doesn’t work. It’s not designed that way “out of the box.” Fortunately there is a way to do this, which will even support redirects between pages, forwards through a RequestDispatcher, and also through standard JSF navigation cases.

There is a 5 minute solution to this problem.

September 9th, 2008 by Lincoln Baxter III

Create a Common Facelets Tag Library: Share it across projects

Tutorial – Step By Step

If you’ve learned to use JSF Facelets to create on-the-fly, simple components using XHTML, then you probably have a whole slew of custom components that need to be copied between various projects, and can be somewhat painful to keep up to date. You may have tried to move them into a jar file, but Facelets can’t find them there (without some help from us.)
August 24th, 2008 by Lincoln Baxter III

Ajax4Jsf <a4j:form data=”broken!”>

A4J:Form is missing several specified ajax functions

(View this issue on the JBoss tracker here. Keep reading, there is a fix… download fix)

The issue:

When using the a4j:form component, the data=”#{managedBean.property}” the properties defined in the data element list are supposed to be available after the a4j event in the data JavaScript variable; however, with <a4j:form> the attribute is not correctly causing the JavaScript data variable to be populated.
August 17th, 2008 by Lincoln Baxter III

Hibernate: Use a Base Class to Map Common Fields

Tutorial Chapter 2 – Easier Development and Maintenance

Tired of wiring in an id, version, and timestamp field into all of your Hibernate objects? There’s an easy way to solve this pain once and for all of your classes. Avoid code-repetition: today’s article focuses on using Hibernate Annotations to map common fields into one mapped superclass. If you have not done so already, and need to get a bare bones hibernate application up and running, this guide should get you up and running in a few minutes.
August 1st, 2008 by Lincoln Baxter III

Replacing Commented Code with Delegated Code

Today’s subject is a well commented square root approximation method. Imagine that this method is buried deep in a very messy Java class. How can we make sure that this code is reusable and that our comments don’t become out of date as our code changes?
/**
 * Approximate the square root of n, to within the specified tolerance,
 * using the Newton-Raphson method. This method takes two arguments:
 * @param Double n The number to be square-rooted
 * @param Double tolerance the error tolerance
 * @return Double result of square root operation
 */
public Double approximateSquareRoot(Double n, Double tolerance)
{
    Double root = n / 2;
    while (Math.abs(root - (n / root)) > tolerance)
    {
        root = 0.5 * (root + (n / root));
    }
    return root;
}