Custom JSF component - Birthday
One of the powerful feature of JSF is to extend its tag library and create custom tags. Developers can use this feature and enhance the tags that are provided by JSF implementations (e.g. sun, myfaces, etc). Or they can straight away start writing the tags of their own. Today we’ll see how easy it is to create a custom tag in JSF. Let’s try out with an example, to create a tag, which will display today’s date and a list of people who has birthday today.Step 1 – web.xml
Make an entry for the custom tags definition file.
We need to define 2 configurations,
URI that will be used when this tag is used inside a JSF page.
Location of the tags definition file.
Step 2 – custom-tags.tld
Create custom-tags.tld in the specified location and mention details about the custom tag.
Here we mention the name of the tag, the class which will provide additional information about this tag.
Step 3 – faces-config.xml
Next step is to modify the faces-config.xml file and make an entry for this tag.
Here we specify 2 configurations,
Source codeDownload the source code for this article.
Get the latest freelance project announcements
ExtraWatch™ FREE is Joomla, Wordpress, Prestashop, Magento plugin with following features: Live Stats, Nightly Email Reports, Goals, Graphs, Anti-spam, History and more