Icefaces custom tag with facelets

I've been struggling with creating my own icefaces tag that I could use everywhere it's needed. There are many tutorials on the internet, BUT.. I couldn't get it work anyway.

When I looked at the sourcecode on the webpage, the tag     <ticker:ticker />  was there directly in the HTML sourcecode. This is wrong, because I expected the rendered ouput there.

One whole week I tried to solve this problem trying almost everything. But then, finally, I found it.

So, what was the problem? When you are using Facelets with your JSF/Icefaces, the TLD (tag library descriptor) files are for nothing. Even if I tried to place them everywhere. You have to create the equivalent of the TLD file for the Facelets - the XML file describing the tag structure. In this case it's ticker.taglib.xml


The tag descriptor for the facelets


 There you specify the component's class - Ticker, and it's renderer - TickerRenderer. Now, you don't need the TickerTag as suggested when using JSP in many tutorials around the internet.

Also don't forget to tell the JSF to recognize your taglib and place this XML snippet into web.xml (just the first reference to xml, the second is when you want to use also another taglib - eg. the tomahawk components)
web.xml facelets libraries
Put the reference to your tag descriptor into web.xml




  JSF source
JSF source with a custom tag

rendered output
Rendered output


I wonder why this 'trick' hasn't been described yet in some tutorial. So, I hope you will find this remark useful and it will help you when creating your own JSF components.





+1 #1 Deckard 2011-01-17 10:13
Thanks, that helped a lot. But now I'm struggeling on the packaging:
For now I am packaging a simple jar file, containing the facelets taglib, a managedbeand and some resources (css and images). The code runs fine, but does not load the resources packaged in the jar.
How would I reference to a gif located in the Component-jar, say in a folder called "resources" when using "ice:graphicImag e": What url should I use in the components xhtml-file?
And, to have it a bit more complex: I don't know whether the component would be used in a simple servlet or in a portlet-application: Are there any differences?
Any idea?
Thanks in advance
0 #2 Joanne Anderson 2013-10-25 00:30
Thanks Jeff for all your hard work and for saving me a lot of effort.

Add comment

Security code