gpt4 book ai didi

jsf - Facelets 自定义标记未呈现

转载 作者:行者123 更新时间:2023-12-05 00:06:36 26 4
gpt4 key购买 nike

我正在尝试使用 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>

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

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

标签是这样调用的:
<!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>

提前谢谢了!

最佳答案

我在这里找到了答案: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 - Facelets 自定义标记未呈现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3118309/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com