I am using JSF 2.0. I created custom JSTL tags with tagfiles and that were working fine in JSP. But I want to use custom JSTL tags in Facelets too. Is it possible to create tagfiles in Facelets or not?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The phrase "custom JSTL tags" makes no sense. JSTL is already a taglib at its own. Read the introductory paragraphs of our JSTL wiki page to learn what JSTL really is. You perhaps actually meant "custom JSP tags". Of course they would not work in Facelets as that’s a completely different view technology than JSP and actually the successor of the deprecated JSP. See also Why Facelets is preferred over JSP as the view definition language from JSF2.0 onwards?
The analogy of a "custom JSP tag" in Facelets is a "custom Facelets tag", or more commonly "Facelets tag file". It’s rather simple, you can follow the same syntax as an include file.
/WEB-INF/tags/some.xhtml:and register it in
/WEB-INF/example.taglib.xmlas follows:which is in turn registered in
/WEB-INF/web.xmlas follows:(note that registration in
web.xmlis unnecessary when the*.taglib.xmlfile is in/META-INFfolder of a JAR in/WEB-INF/lib)and finally use it in your templates as follows:
See also: