Coming Up for Air

JSF and Annotations

Friday, April 14, 2006 |

Recently at work, we looked, ever so briefly, at a new web framework called Stripes. It looked rather cool, as it was largely annotation-based, but, given its glaring lack of any wide-spread usage, we never seriously considered it. Today, I was on The Server Side (you do read TSS, right? ;) ) and noticed that Struts has released a Java 5 addon. One of the additions is annotation support whose only problem appears to be that it’s tied to Struts (that’s a joke ;) ).

At any rate, all of this annotation on the web tier got me to thinking (again) about my favorite Java web tier technology, JSF. The only "real" complaint I have with the framework is the XML, minimal as it is (I’m past the JSF learning curve, so I don’t have a problem with that anymore :) ). Being a big fan of annotations and IoC, I’ve been wondering if/when JSF will finally support configuration via annotations. Until this morning, I’ve just assumed that I won’t see that support until 2.0, but a thought occured to me: why can’t it be bolted on to 1.x?

In the interest of full disclosure, I’ve never written my own annotations, and I’m not too terribly familiar with the internals of either major JSF implementation, but I have in my mind a back-of-a-napkin sketch of a possible solution. My initial guess is that it might be possible to write a class (a FacesServlet child, maybe) that scans the classpath (optionally restricted by context-params, for example) looking for annotated classes and methods. Armed with the knowledge gleaned from the scan, we would then be able to build the context (I’m hoping) in a similar fashion to parsing faces-config.xml.

Is it doable? Am I off my rocker? I don’t know. Hopefully, I’ll have a chance to find out soon, assuming someone in the know doesn’t disabuse of the notion before I get started. :)

World’s Fastest Update: Ed Burns gave me this link, which looks to be exactly what I was looking for. That will save me a lot of time. :)

Search

    Quotes

    Sample quote

    Quote source

    About

    My name is Jason Lee. I am a software developer living in the middle of Oklahoma. I’ve been a professional developer since 1997, using a variety of languages, including Java, Javascript, PHP, Python, Delphi, and even a bit of C#. I currently work for Red Hat on the WildFly/EAP team, where, among other things, I maintain integrations for some MicroProfile specs, OpenTelemetry, Micrometer, Jakarta Faces, and Bean Validation. (Full resume here. LinkedIn profile)

    I am the president of the Oklahoma City JUG, and an occasional speaker at the JUG and a variety of technical conferences.

    On the personal side, I’m active in my church, and enjoy bass guitar, running, fishing, and a variety of martial arts. I’m also married to a beautiful woman, and have two boys, who, thankfully, look like their mother.

    My Links

    Publications