Custom tags are a very useful feature of JSF. They are demonstrated in the planets example which can be run here. This example defines a <corejsf:planet> tag that is used for each of the planet buttons. Each use of the tag specifies three attributes:

Use of the custom tags technology involves doing four things:

Web Pages/sections/planetarium/sidebar.xhtml

A <ui:composition> tag is used to define a custom tag. The attributes of the new tag are defined just by being mentioned in Expression Language markup. In a <corejsf:planet> tag

The <h:commandLink> tag with a graphics image acts just like a <h:commandButton>. Its appearance is controlled using an EL conditional expression to determine the style class. This makes the background color lighter if the planet is selected.

Web Pages//WEB-INF/tags/corejsf/planet.xhtml

Before a custom tag can be used, it must be declared in a tag library file containing:

Web Pages/WEB-INF/corejsf.taglib.xml

Finally, the tag library file must be registered in the web.xml configuration file by adding a <context-param> tag.

Web Pages/WEB-INF/web.xml