How To Create Your Own JSF Components


In this tutorial we have created new JSF components all the way from scratch to a deployable package. In this example, we have covered the major points you will need in order to create any JSF component. However, our example does not show all of the aspects of JSF component building. You now have just the basic knowledge. If writing JSF components is going to be your job, you will need to learn more before you will become an expert in this area.

Additional Topics

Some of the aspects you will need to learn that were not covered in this tutorial are mentioned below.

Processing user input. If your component accepts data entered or selected by the user, you need to take care of encoding or decoding the date. Such a component might need to support validators, value changed listener, data converters.

Working with Facets. Facets are similar to children, but they have names. It is up to the component how to process them. For example, the gridPanel from the standard JSF library has two facet elements for header and footer. It does not matter where the facet is located in the JSP code, the renderer always puts the header at the top and footer at the bottom.

Custom rendering of the existing components. In our example, the getRendererType method of the TickerTag returns null. This means that the component renders itself. If this method returns any value, it makes it possible to overwrite the default rendering provided by the UITicker class. For this purpose, you or anybody else can add a new renderer with the defined name to the render-kit section of the faces configuration file. In the same way, you can implement rendered for any standard JSF components. All of the render type names can be found in the JSF specification.

Action components. You can extend your component from the UICommand class. This allows you to write components similar to a command button or a link, but with advanced behavior. For example, you can implement tabbed panels or drop-down menus.

JSF Resources

Beyond this tutorial, there are many resources that will help you go further with JSF. There are already a number of published books dedicated to JavaServer Faces. We recommend reading chapter 9 of the Core JavaServer Faces book by David Geary and Cay Horstmann. It contains very useful information regarding JSF component development.

There are also several other types of resources available. We support the www.jsftutorials.net Web site where you can read other JSF tutorials. Also, if you or your company are interesting in learning JSF technology, Exadel, Inc. has introduced a new JSF Course. We are going to prepare several more courses that cover all levels from beginner to expert. The first course for beginners will be completed in the near future. For more information visit our corporate Web site at www.exadel.com


what do you think of this tutorial?
Excellent! (5) Nice job (4) Just OK (3) Not so good (2) Worthless! (1)
what other tutorials would you like to see?
comments?

(if you would like a reply to your feedback, please don't forget to include your email address)