Skip to main content

Creating JSF Custom Components

Posted by daniel on July 16, 2004 at 9:00 AM PDT

A credit card validation example

A couple of summers ago I was trying to book a train to New York city. When I got to the place on the form that allowed me to enter my AAA (American Automobile Association) membership number to receive an extra discount, I kept getting an error message. I tried the number with spaces and without. I tried it with the dashes and without. Nothing worked. Finally, I called their help line and was told in a tone that implied that I had missed something obvious, that I needed to leave the first four digits off of the form.

Bill Dudney shows you how to build a credit card validator in his article Creating JSF Custom Components. Bill responds to " one common misconception with JSF. JSPs are not the only way to compose a JSF user interface. In fact, it is fairly straightforward to build a JSF user interface in a servlet or in a plain Java class. JSPs were chosen as the "default" way to build JSF interfaces because of the broad knowledge base that exists in building web applications with JSPs."

His article provides a nice beginning example of a simple component built using JSF. But, Dudney says, "Many custom components will be as simple as this; of course, there are many that will be more complex. And, no surprise, the complexity of the code depends directly on the complexity of the component being written. As an example, the calendar component in the MyFaces project is about 125 lines of generated code. This component is so simple because it is not adding any additional data fields to UIInput, so it's able to reuse most of the functionality of its superclass."

Max Goff joins us as a blogger. I had the pleasure of meeting Max a few years ago at a JavaOne BoF I presented on swarms. We kept bumping into each other at the emerging technology talks.
In today's
Weblogs, Max introduces himself in To Blog or not to Blog....

Jonathan Simon questions whether or not there is a JavaOne effect in the job market. He has noticed that after searching for a Swing developer in NYC for a couple of months, in the time since JavaOne he is "seeing a lot more Java developers now than I was a month or two ago."

Bruce Tate has again written a subtle blog that may seem to be about A strange car but seems to be a metaphorical discussion of middleware.

In Also in Java Today , David Walend is a true hacker. He writes in Test Driving Generics that after JavaOne "To relax on the way home, I started stitching generics into JDigraph, a general library for representing directed graphs." He describes how he used generics to specify what type of objects an instance of his Bag collection can contain. He goes on to describe how he integrated generics in more complicated collections.

In part 2 of an excerpt from Better, Faster, Lighter Java, Bruce Tate and Justin Gehtland continue to rework the Pet Store example, adding persistence, a facade (to make dealing with the model easier), and a web interface. These two parts are not intended to be a comprehensive look at Spring, but are meant to give you an overall understanding and to get you up and going with an example.

In today's Forums, mthornton asks again What sort of compatibility are we talking about? "What does compliance actually mean when the meaning of the specification is open to doubt. The spec has improved with time (just look at the documentation for things like File.renameTo over a series of revisions), but no doubt there remain many loop holes and even erroneous statements."

Cowwoc thinks that we need to Make interacting with Sun easier and less formal!

Sun can retain control of Java, design and interfaces for as long as it wants (I don't think many people will argue with that) but it *has* to make it easier to use to build the source-code, submit patches and have them merged into Sun's main-branch for monthly releases. "

In Projects and Communities, Java Games is spotlighting Grex Engine which has two layers - " one which provides low-level features and non-gameplay systems, and another which contains all the game-logic and game-specific systems."

The Java AVK is a free test suite that verifies "an application for correct use of standard J2EE APIs, scan for proprietary code, test a WAR or EAR file against the J2EE SDK for runtime exceptions, and generate an html-based report summarizing results."

In today's News Headlines

Registered users can submit news items for the href=""> News Page using
our news submission
. All submissions go through an editorial review before being posted to the site. You can also subscribe to
News RSS feed

Current and upcoming
Java Events

Registered users can submit event listings for the href=""> Events Page using our href=""> events submission
form. All submissions go through an editorial review before being
posted to the site.

Archives and Subscriptions: This blog is delivered weekdays as the
Today RSS feed
. Also, once this page
is no longer featured as the front page of
it will be archived along with other past issues in the href=""> Archive.