gpt4 book ai didi

jsf - :outputScript with target ="head" not working with Primefaces 3. 5

转载 作者:行者123 更新时间:2023-12-02 21:56:58 25 4
gpt4 key购买 nike

我有一个 JSF 应用程序,其中使用 target="head"属性插入了一些脚本,但在将 Primefaces 3.5 包含到类路径后,这些脚本停止渲染。

这是页面代码:

<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
</h:head>
<h:body>
<h:outputScript target="head">
function a(){};
</h:outputScript>
</h:body>
</html>

删除目标属性可以使脚本正常显示,但在正文中,而不是在头部......

有什么线索吗?感谢和问候。

最佳答案

自 PrimeFaces 3.0 起,出现了新的 HeadRenderer它允许可定制的资源排序。另请参阅this blog 。这已经覆盖了标准 JSF 头部渲染器。这本身没问题,但显然它无法正确识别带有 head 目标的内联脚本。这显然是 PrimeFaces 头部渲染器中的一个错误。你最好的选择是 report这个问题交给PF们。

同时,如果您根本没有使用新的 PrimeFaces 功能,那么只需输入 Mojarra's own HeadRenderer通过将以下条目添加到 faces-config.xml 中恢复为默认头部渲染器:

<render-kit>
<renderer>
<component-family>javax.faces.Output</component-family>
<renderer-type>javax.faces.Head</renderer-type>
<renderer-class>com.sun.faces.renderkit.html_basic.HeadRenderer</renderer-class>
</renderer>
</render-kit>

注意:如果您使用 MyFaces 而不是 Mojarra,显然请引用 MyFaces 自己的。

关于jsf - :outputScript with target ="head" not working with Primefaces 3. 5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17582476/

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