我问这个问题,因为我已经有条件地基于bean属性值来渲染h:head,如下所示:<h:head rendered="#{!pageNavigationController.gmaps and !pageNavigationController.gmapsAutoComplete}"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="refresh" content="#{session.maxInactiveInterval};url=pf_viewExpired.jsf" /> <title><h:outputText escape="false" value="MCMS"/></title> <h:outputStylesheet name="css/mcms.css"/> <h:outputScript name="js/mcms.js"/> <h:outputScript name="js/addUsingTemplate.js" rendered="#{pageNavigationController.isPageSelected('/orders/pf_AddUsingTemplate.xhtml')}"/></h:head>由于对页面上多个h:head的条件渲染,也许我对h:head的使用使TomTo 1.5 SNAPSHOT容器难以提供.js文件,或者实际上可能是PrimeFaces Push( Atmosphere)问题最终需要解决,但是我敢肯定,如果尚未在h:head中呈现该文件,则可以通过h:outputScript呈现该.js文件.该Web应用程序正在使用以下内容: PrimeFaces 3.5快照,TomEE 1.5快照(Tomcat 7.0.32),JUEL 2.2.5,OmniFaces 1.3快照请告知.解决方案这似乎更像是PrimeFaces问题.为了在同一视图上的每个请求上强制加载push.js,您可以显式添加一个<h:outputScript library="primefaces" name="push/push.js" target="head" />没有条件渲染.如果一切顺利,即按照JSF2资源处理机制运行良好,则在正常工作的情况下,不应将其全部包含两次.PrimeFaces conditionally renders the following in h:head:<script type="text/javascript" src="/webapp/javax.faces.resource/push/push.js.jsf?ln=primefaces"><!--//--></script>when PrimeFaces p:socket component is added to JSF/xhtml page. Some of my page refreshes, result in this push.js file 'not' being rendered in h:head.When push.js file is 'not' rendered, I would like to conditionally render the push.js file in attempt to fix/workaround an issue I'm having with PrimeFaces Push.For more details, please click PrimeFaces forum topic URL below:Uncaught TypeError: undefined is not a functionI am asking this question, because I am already conditionally rendering h:head based on bean attribute values, such as the following:<h:head rendered="#{!pageNavigationController.gmaps and !pageNavigationController.gmapsAutoComplete}"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="refresh" content="#{session.maxInactiveInterval};url=pf_viewExpired.jsf" /> <title><h:outputText escape="false" value="MCMS"/></title> <h:outputStylesheet name="css/mcms.css"/> <h:outputScript name="js/mcms.js"/> <h:outputScript name="js/addUsingTemplate.js" rendered="#{pageNavigationController.isPageSelected('/orders/pf_AddUsingTemplate.xhtml')}"/></h:head>Maybe my use of h:head is making it difficult for the container TomEE 1.5 SNAPSHOT to serve the .js file, because of the conditional rendering of multiple h:head on the page, or this may actually be a PrimeFaces Push (Atmosphere) issue that ultimately needs to be solved, but I'm sure there is a way to render the .js file via h:outputScript, if the file is not rendered in h:head already.The web application is using the following:PrimeFaces 3.5 SNAPSHOT, TomEE 1.5 SNAPSHOT (Tomcat 7.0.32), JUEL 2.2.5, OmniFaces 1.3 SNAPSHOTPlease advise. 解决方案 This seems more like a PrimeFaces issue. In order to force loading of push.js on every request on the same view, you could explicitly add a<h:outputScript library="primefaces" name="push/push.js" target="head" />without conditional rendering. If everything went well, i.e. it behaves well as per JSF2 resource handling mechanism, then it should not be included twice at all in cases where it worked properly. 这篇关于如果在全页刷新(FPR)之后未呈现文件,我该如何有条件地在h:head中呈现.js文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-22 19:47
查看更多