Facelets custom tag not rendering

primefaces custom tags
custom tag jsf
jsf tags
taglib xhtml
jsf composite component
jsf components

I am trying to create a custom tag with Facelets but it isn't rendering (i.e. the tag appears unreplaced in the response).

The tag (/WEB-INF/facelets/tags/inputThumbnailSelector.xhtml):

<html xmlns="http://www.w3.org/1999/xhtml"
   xmlns:f="http://java.sun.com/jsf/core"
   xmlns:h="http://java.sun.com/jsf/html"
   xmlns:ui="http://java.sun.com/jsf/facelets"
   xmlns:t="http://myfaces.apache.org/tomahawk">

<ui:composition>
 <div style="position: relative;">
  <img style="position: absolute; left: 0; top: 0;" src="#{image}"/>
  <div class="thumbnail-selector" style="position: absolute; left: #{backingBean.thumbnailLeft}; top: #{backingBean.thumbnailTop};"/>
 </div>
</ui:composition>

</html>

/WEB-INF/facelets/tags/panayk.taglib.xml:

<!DOCTYPE facelet-taglib PUBLIC "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN" "http://java.sun.com/dtd/facelet-taglib_1_0.dtd">

<facelet-taglib>
 <namespace>http://panayk.endofinternet.org/jsf</namespace>
 <tag>
  <tag-name>inputThumbnailSelector</tag-name>
  <source>inputThumbnailSelector.xhtml</source>
 </tag>
</facelet-taglib>

My web.xml contains:

<context-param>
 <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
 <param-value>/WEB-INF/facelets/tags/panayk.taglib.xml</param-value>
</context-param>

This is how the tag is called:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
   xmlns:f="http://java.sun.com/jsf/core"
   xmlns:h="http://java.sun.com/jsf/html"
   xmlns:ui="http://java.sun.com/jsf/facelets"
   xmlns:t="http://myfaces.apache.org/tomahawk"
   xmlns:my="http://panayk.endofinternet.org/jsf">

<ui:composition template="/layout/layout.xhtml">
...  
   <my:inputThumbnailSelector image="${facesContext.externalContext.requestContextPath}/image/get.servlet?id=1" 
            backingBean="#{entryHandler}"/>
...
</ui:composition>

</html>

Many thanks in advance!

I found my answer here: https://community.oracle.com/thread/1719525

I think I found the problem and the solution (which is not 100% correct). The context param should be facelets.LIBRARIES not javax.faces.FACELETS_LIBRARIES.

The context param javax.faces.FACELETS_LIBRARIES is supposed to replace the deprecated (deprecated as per JSF specification) context param facelets.LIBRARIES. When the latter is used there is a warning in the logs during server startup saying facelets.LIBRARIES is deprecated and javax.faces.FACELETS_LIBRARIES should be used instead. But I think this is only used for logging a warning, i.e. still the name facelets.LIBRARIES is used to build custom taglib components. I'm saying this is not 100% correct because it should work with the new parameter name. There are other parameters which have got new names, but I didn't test them yet.

jsf - Facelet Custom Component - prevent rendering, However, per the documentation on the facelets development site, it appears that <ui:fragment> tags only supports two attributes, id and binding . So, even if  After reading this answer, I am still stumped.I agree that JSTL should be avoided and understand how its evaluation occurs in the wrong phase. However, per the documentation on the facelets development site, it appears that <ui:fragment> tags only supports two attributes, id and binding.

I recommend doing your tags like this:

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
   xmlns:f="http://java.sun.com/jsf/core"
   xmlns:h="http://java.sun.com/jsf/html"
   xmlns:ui="http://java.sun.com/jsf/facelets"
   xmlns:t="http://myfaces.apache.org/tomahawk">

 <div style="position: relative;">
  <img style="position: absolute; left: 0; top: 0;" src="#{image}"/>
  <div class="thumbnail-selector" style="position: absolute; left: #{backingBean.thumbnailLeft}; top: #{backingBean.thumbnailTop};"/>
 </div>
</ui:composition>

but everything seems ok, since you use a layout, did you wrap the custom tag in a ui:define like this ?

<ui:define name="body">
<my:inputThumbnailSelector image="${facesContext.externalContext.requestContextPath}/image/get.servlet?id=1" 
            backingBean="#{entryHandler}"/>
</ui:define>

Custom tag does not render. (JSF forum at Coderanch), How ever when I run my solution, I notice in the source code that the custom tag is not rendered and the radio buttons were not displayed. ui:fragment rendered attribute not working after upgrading Facelets to JSF 2 stackoverflow.com. I am upgrading a project from JSF1.2/Facelets1.1 to JSF2.1 with built in facelets. The following no longer works and I don't know why. Both ui:fragments apparently evaluate to true,

Make sure your *.taglib.xml is well configured. It happen I had the wrong namespace and it did not work. immediately as I've changed it it worked, I had auto complete (aka. code completion)

<facelet-taglib version="2.2"
            xmlns="http://xmlns.jcp.org/xml/ns/javaee"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facelettaglibrary_2_2.xsd">
</facelet-taglib>

Related links:

JSF 2.2: New namespaces

Packaging Facelets files (templates, includes, composites) in a JAR

Render « Facelets « JSF Q&A, Facelets custom tag not rendering stackoverflow.com I am new to JSF, but my JSF tags are not rendered in xhtml file, i tried out every possible solution, but  Custom PrimeFaces component not rendering Tag: jsf , primefaces , jboss7.x I'm in the process of writing a set of custom PrimeFaces components, using PrimeFaces 5.0 and running inside JBoss EAP 6.2.

Custom tags in JSF 2.0 – Mkyong.com, In JSF 2.0, you are allow to create your custom tag to render a pre-defined content. A custom tag is xmlns:ui="http://java.sun.com/jsf/facelets" > <h:body> This is not a custom component, this is an example for composition. Facelets supports tags for composite components, for which you can declare custom prefixes. For more information on composite components, see Composite Components. The namespace prefixes shown in the table are conventional, not mandatory. As is always the case when you declare an XML namespace,

JSF - Custom Tag, JSF - Custom Tag - JSF provides the developer with a powerful capability to define own custom tags, which can be used to render custom contents. S.No, Node & Description. 1. facelet-taglib <facelet-taglib> <namespace>http://​tutorialspoint.com/facelets</namespace> <tag> <tag-name>buttonPanel</tag-​name>  The define tag and insert tag is used in combination to print the values in the insert tag. We will look at the example in the later sections of the post. <ui:fragment> tag. The <ui:fragment> tag includes the new UI component instance into the JSF Component tree. JSF does not discard the contents outside this tag. The tag attributes are;

JSF Custom Components: Tag Files, Composite , JSF Custom Components: Tag Files, Composite Components & Custom Different facelets application can refer to same template to render pages with a in an jsf component, that attribute is dropped ie. not rendered in the resultant html​) What Is Facelets? Facelets is a powerful but lightweight page declaration language that is used to build JavaServer Faces views using HTML style templates and to build component trees. Facelets features include the following: Use of XHTML for creating web pages. Support for Facelets tag libraries in addition to JavaServer Faces and JSTL tag

Comments
  • Anyone? This still isn't working.
  • @Panyiotis Karabassis: Thank you, this saved my day. My problem was using facelet instead of facelets
  • You are welcome! Is this is still a problem, then? I haven't programmed JSF in a while, but I just purchased the "Core JavaServer Faces" book (very promising) which is about JSF2.0 with facelets as the default view layer. Shouldn't it work 'out of the box' now?
  • In the "Core Javaserver Faces" the author used both javax.faces.FACELETS_LIBRARIES and acelets.LIBRARIES which is really confusing
  • Yes I wrapped it in a ui:define. Thank you!