aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "How to create JSF custom tag" Watch "How to create JSF custom tag" New topic
Author

How to create JSF custom tag

Srinivasa Murari
Greenhorn

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

Thanks
Sri
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Joachim Skeie
Greenhorn

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

Thanks
Sri


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.
 
jQuery in Action, 2nd edition
 
subject: How to create JSF custom tag