OmniFaces を使用してCombinedResourceHandlerリソースを一度にストリーミングしたいと考えています。
CombinedResourceHandler documentationfaces-config.xmlで説明されているように、追加の構成パラメーターなしで登録しました。
CSS リソースでは問題なく動作しますが、JavaScript リソースでは何もしません。ここに私のテストがあります:
<!DOCTYPE html>
<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:o="http://omnifaces.org/ui">
<h:head>
<title>CombinedResourceHandlerTest</title>
<h:outputStylesheet name="css/bootstrap-3.3.5/bootstrap.css"/>
<h:outputStylesheet name="css/main.css" />
<h:outputScript name="js/jquery/jquery.min.js"/>
<h:outputScript name="js/bootstrap-3.3.5/bootstrap.min.js"/>
</h:head>
<h:body>
<f:view>
<h2>CombinedResourceHandlerTest</h2>
</f:view>
</h:body>
出力:
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="j_idt2">
<title>CombinedResourceHandlerTest</title>
<script type="text/javascript" src="/testApp/javax.faces.resource/js/jquery/jquery.min.js"></script>
<script type="text/javascript" src="/testApp/javax.faces.resource/js/bootstrap-3.3.5/bootstrap.min.js"></script>
<link type="text/css" rel="stylesheet" href="/testApp/javax.faces.resource/eNpLLi7WT8rPLykuKUos0DXWM9YzRfD1kouLa4BYPzcxMw_EAQCLpxEP.css?ln=omnifaces.combined&v=1480321351184">
</head>
属性 target="head" で試しました:
<h:head>
<h:outputScript name="js/jquery/jquery.min.js" target="head"/>
</h:head>
...
出力: (スクリプトが完全に欠落しています):
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="j_idt2">
<title>CombinedResourceHandlerTest</title>
<link type="text/css" rel="stylesheet" href="/testApp/javax.faces.resource/eNpLLi7WT8rPLykuKUos0DXWM9YzRfD1kouLa4BYPzcxMw_EAQCLpxEP.css?ln=omnifaces.combined&v=1480321351184">
</head>
...
</html>
スクリプトを本体の上に移動すると、スクリプトも欠落します。
<h:body>
<h:outputScript name="js/jquery/jquery.min.js" target="head"/>
....
</h:body>
ソースを調べた後、私も試しました
<o:deferredScript name="js/jquery/jquery.min.js"/>
このケースの出力を調べたところ、combinend スクリプトには最初のスクリプトしか含まれておらず、コンソールに「ReferenceError: OmniFaces is not defined」と表示されていることがわかりました。
<body>
<script type="text/javascript">OmniFaces.DeferredScript.add('/testApp/javax.faces.resource/eNpLL81JLE7OsMoq1s8qLE0tqoRSermZeXpZxQDDagwa.js?ln=omnifaces.combined&v=0');</script>
</body>
そして気がついたのは、アクティブjsf.jsを持っているときさえ含まれていないということです。CombinedResourceHandlerブラウザのコンソールに「mojarra が定義されていません」と表示されます。
私は何を間違っていますか?前もって感謝します!
私の環境は: Mojarra 2.2.12、Omnifaces 2.5.1、Tomcat 8.