Showing posts from May, 2012

Simple Java based JSF 2.2 custom component

In JSF components play a central role, it being a component based framework after all. As mentioned in a previous blog posting , creating custom components was a lot of effort in JSF 1.x, but became significantly easier in JSF 2.0. Nevertheless, there were a few tedious things left that needed to be done if the component was needed to be used on a Facelet (which is the overwhelmingly common case); having a -taglib.xml file where a tag for the component is declared, and when the component's Java code resides directly in a web project (as opposed to a jar) an entry in web.xml to point to the -taglib.xml file. In JSF 2.2 these two tedious things are not needed anymore as the Facelets component tag can be declared using the existing @FacesComponent annotation . As an update to the original blog posting, a simple Java based custom component can be created as follows: components/ @FacesComponent(value = "components.CustomComponent", createTag