Facelets自定义标签未呈现

编程入门 行业动态 更新时间:2024-10-09 01:17:28
本文介绍了Facelets自定义标签未呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用Facelets创建一个自定义标签,但该标签无法呈现(即该标签在响应中显示为未替换).

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

标记(/WEB-INF/facelets/tags/inputThumbnailSelector.xhtml):

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

<html xmlns="www.w3/1999/xhtml" xmlns:f="java.sun/jsf/core" xmlns:h="java.sun/jsf/html" xmlns:ui="java.sun/jsf/facelets" xmlns:t="myfaces.apache/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:

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

<!DOCTYPE facelet-taglib PUBLIC "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN" "java.sun/dtd/facelet-taglib_1_0.dtd"> <facelet-taglib> <namespace>panayk.endofinternet/jsf</namespace> <tag> <tag-name>inputThumbnailSelector</tag-name> <source>inputThumbnailSelector.xhtml</source> </tag> </facelet-taglib>

我的web.xml包含:

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>

这是标签的调用方式:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="www.w3/1999/xhtml" xmlns:f="java.sun/jsf/core" xmlns:h="java.sun/jsf/html" xmlns:ui="java.sun/jsf/facelets" xmlns:t="myfaces.apache/tomahawk" xmlns:my="panayk.endofinternet/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/thread/1719525

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

我认为我找到了问题和解决方案(并非100%正确). 上下文参数应该为facelets.LIBRARIES而不是javax.faces.FACELETS_LIBRARIES .

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.

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

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.

更多推荐

Facelets自定义标签未呈现

本文发布于:2023-11-28 04:36:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1640991.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   标签   Facelets

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!