views:

296

answers:

2

Is someone using Facelets with JSP 2.0 tags? How to add tag library to xhtml page? In JSP I used:

<% taglib prefix="example" tagdir="/WEB-INF/tags/my" %> 
and : <example:sample/>

How can I do the same in facelets with JSP 2.0 tags?

+1  A: 

In Facelet XHTML you would add a taglib in the following way:

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:c="http://java.sun.com/jstl/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"&gt;
Allan Lykke Christensen
Allan I know that I can use xmlns to include external library, but I need to write my own tags (with scirptlets or another java code) and I have to put this write code like a tag in xhtml page. Can I do that? In JSP pages it was very simple, but I don't know the Facelets very good.
przemek
Certainly, it works in the same way. Once you have created your tags in Facelets, you can import them using xmlns. I've got a simple example of creating and using a custom Facelets tag here: http://blogs.i2m.dk/allan/2008/03/18/example-of-using-custom-facelet-tags/
Allan Lykke Christensen
Thanks, I was looking for something like this.
przemek
+2  A: 

Facelets and JSP are mutually exlusive - they are two different view technologies.

Some JSP tags are ported to facelets, using the facelets tag library descriptors.

So if you want to define facelets tags, add the appropriate descriptors.

Bozho