File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes How to create JSF custom tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "How to create JSF custom tag" Watch "How to create JSF custom tag" New topic

How to create JSF custom tag

Srinivasa Murari

Joined: Jul 27, 2009
Posts: 2
I am new to JSF, looking for steps how to create Custom Tomahawk JSF tag.

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

The only way to create a custom Tomahawk tag is to join the Apache Tomahawk project and get accepted as a committer.

You can create your own custom JSF tags, however, and they can interact with Tomahawk (or not) as you prefer.

The process of creating a custom JSF tag is not simple, however. It's quite a bit more complicated than creating a custom JSP tag, since in JSF, you break the functionality into rendering and non-rendering parts, and may have multiple renderers. I got my info for doing this from Kito Mann's "JSF In Action" book.

An IDE is no substitute for an Intelligent Developer.
Joachim Skeie

Joined: Jun 19, 2009
Posts: 8
Srinivasa Murari wrote:I am new to JSF, looking for steps how to create Custom Tomahawk JSF tag.


Preferably, you need a set of classes, and TLD (Tag Library Descriptor Class) and a faces-config XML file for your component.

In my own custom components I usually end up with classes like

MyComponentName - A Component class that extends UICommand, and at the least overrides the methods getFamily, processDecodes and getRendersChildren
MyComponentNameTag - A Component class that is responsible for setting and storing all the attributed that the component has
MyComponentRenderer - A Component class that is responsible for rendering the HTML/JavaScript/XML/etc of your component
MyComponent.tld - A Tag Library Descriptor file that describes the component, each and every attribute, its type and purpose (this is sort of like an XML representation of the *Tag class above)
faces-config.xml - The librarys configfile that tells JSF how to weave the classes above together into a component

Then you have other options as well, such as including a *-taglib.xml file so that Facelets can understand the component, etc.

However, if creating components is all new to you, you should read up on it. JSF in Action is a very decent book. The Sun JSF tutorial (Part of the JEE tutorial) is also quite good (IMO), and is the guide from which I learned to write Custom Components.

Its rather hard for anyone on the forum to be specific for your needs, just because you are asking a very wide quiestion, to which there are many different approaches and possible solutions to. There is also a rather decent learning curve involved.
wood burning stoves
subject: How to create JSF custom tag
It's not a secret anymore!