Facelets自定义标记无法呈现

Pan*_*sis 4 jsf facelets

我正在尝试使用Facelets创建自定义标记,但它不呈现(即标记在响应中显示为未替换).

标签(/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>
Run Code Online (Sandbox Code Playgroud)

/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>
Run Code Online (Sandbox Code Playgroud)

我的web.xml包含:

<context-param>
 <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
 <param-value>/WEB-INF/facelets/tags/panayk.taglib.xml</param-value>
</context-param>
Run Code Online (Sandbox Code Playgroud)

这是标记的调用方式:

<!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>
Run Code Online (Sandbox Code Playgroud)

提前谢谢了!

Pan*_*sis 7

我在这里找到了答案:https://community.oracle.com/thread/1719525

我想我发现了问题和解决方案(这不是100%正确).上下文PARAM应该是facelets.LIBRARIES没有javax.faces.FACELETS_LIBRARIES.

上下文参数javax.faces.FACELETS_LIBRARIES应该替换已弃用的(根据JSF规范弃用)上下文参数facelets.LIBRARIES.当使用后者时,在服务器启动期间日志中会出现警告,说不facelets.LIBRARIES推荐使用,而javax.faces.FACELETS_LIBRARIES应该使用它.但我认为这仅用于记录警告,即该名称仍facelets.LIBRARIES用于构建自定义taglib组件.我说这不是100%正确,因为它应该与新的参数名称一起使用.还有其他参数有新名称,但我还没有测试它们.