My JSF Books/Videos My JSF Tutorials OmniFaces/JSF PPTs
JSF 2.3 Tutorial
JSF Caching Tutorial
JSF Navigation Tutorial
JSF Scopes Tutorial
JSF Page Author Beginner's Guide
OmniFaces 2.3 Tutorial Examples
OmniFaces 2.2 Tutorial Examples
JSF Events Tutorial
OmniFaces Callbacks Usages
JSF State Tutorial
JSF and Design Patterns
JSF 2.3 New Features (2.3-m04)
Introduction to OmniFaces
25+ Reasons to use OmniFaces in JSF
OmniFaces Validators
OmniFaces Converters
JSF Design Patterns
Mastering OmniFaces
Reusable and less-verbose JSF code

My JSF Resources ...

Java EE Guardian
Member of JCG Program
Member MVB DZone
Blog curated on ZEEF
OmniFaces is an utility library for JSF, including PrimeFaces, RichFaces, ICEfaces ...

[OmniFaces Utilities] - Find the right JSF OmniFaces 2 utilities methods/functions

Search on blog

Petition by Java EE Guardians


miercuri, 28 ianuarie 2015

JSF 2.2 - Creating a Custom TagHandlerDelegate Skeleton

In order to write and configure a TagHandlerDelegate, you have to accomplish three steps:

·         extract the TagHandlerDelegate and override its methods

public class CustomTagHandlerDelegate extends TagHandlerDelegate {

 private TagHandlerDelegate tagHandlerDelegate;

 public CustomTagHandlerDelegate() {

 public CustomTagHandlerDelegate(TagHandlerDelegate tagHandlerDelegate) {
  this.tagHandlerDelegate = tagHandlerDelegate;

 public MetaRuleset createMetaRuleset(Class type) {
  return tagHandlerDelegate.createMetaRuleset(type);

 public void apply(FaceletContext ctx, UIComponent comp) throws IOException {
  tagHandlerDelegate.apply(ctx, comp);

·         Extend the TagHandlerDelegateFactory and point your TagHandlerDelegate

public class CustomTagHandlerDelegateFactory extends TagHandlerDelegateFactory {
    private TagHandlerDelegateFactory tagHandlerDelegateFactory;

    public CustomTagHandlerDelegateFactory() {

    public CustomTagHandlerDelegateFactory(TagHandlerDelegateFactory tagHandlerDelegateFactory) {
        this.tagHandlerDelegateFactory = tagHandlerDelegateFactory;

    public TagHandlerDelegate createComponentHandlerDelegate(ComponentHandler owner) {       
        return new CustomTagHandlerDelegate(tagHandlerDelegateFactory.createComponentHandlerDelegate(owner));

    public TagHandlerDelegate createValidatorHandlerDelegate(ValidatorHandler owner) {      
        return tagHandlerDelegateFactory.createValidatorHandlerDelegate(owner);

    public TagHandlerDelegate createConverterHandlerDelegate(ConverterHandler owner) {     
        return tagHandlerDelegateFactory.createConverterHandlerDelegate(owner);

    public TagHandlerDelegate createBehaviorHandlerDelegate(BehaviorHandler owner) {      
        return tagHandlerDelegateFactory.createBehaviorHandlerDelegate(owner);

·         configure the your custom TagHandlerDelegateFactory in faces-config.xml


Now, most probably, you will go in the apply() method and "play" with the component tree, during its construction.

Niciun comentariu :

Trimiteți un comentariu


Postări populare

OmniFaces/JSF Fans

Follow by Email

Visitors Starting 4 September 2015

Locations of Site Visitors