Apache MyFaces
Project Documentation

Creating Custom JSF Tags

A JSF Tag needs the following elements:

  • JSP Tag class.
  • Tag entry on tld.
  • Facelets Tag Handler class (optional).
  • Tag entry on facelets taglib (optional).

Myfaces builder plugin provide annotations/doclets to help users maintain configuration files. In this way, all information for a tag is just in one file.

Any tag is registered on facelets taglib if it has a related tag handler. Usually, custom tag classes should have facelets tag handlers with similar functions, but on facelets world there is no need to define properties on a xml file.

Setting up your project

All information related can be found here.

Configuration files (faces-config.xml, .tld, facelets taglib)

This page shows some examples.

Annotate JSF Tag Classes

Just add the annotations/doclets as presented below:

    name = "f:valueChangeListener",
    bodyContent = "empty")
public class ValueChangeListenerTag extends 
    GenericListenerTag<EditableValueHolder, ValueChangeListener>

    /** ............. some code goes here ................. **/
        className = "java.lang.String",
        rtexprvalue = true)
    public void setType(ValueExpression type)

        className = "javax.faces.event.ValueChangeListener",
        rtexprvalue = true)
    public void setBinding(ValueExpression binding)