Facelets Custom Tag Not Displaying

I am trying to create my own tag with Facelets, but this is not rendering (i.e. the tag does not appear in the response).

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>

So 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>

Thank you very much in advance!

+3
source share
2 answers

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

I think I found a problem and solution (which is not 100% correct). The context parameter must facelets.LIBRARIESnot bejavax.faces.FACELETS_LIBRARIES .

, javax.faces.FACELETS_LIBRARIES ( JSF) param facelets.LIBRARIES. , , facelets.LIBRARIES , javax.faces.FACELETS_LIBRARIES. , , .. facelets.LIBRARIES taglib. , 100% , . , , .

+7

:

<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>

, , ui: define ?

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

Source: https://habr.com/ru/post/1751758/


All Articles