本の例を複製しようとしていますが、
構造は、以下に添付された画像から視覚化できます-
更新しました
ライブラリが使用されるビューは、以下に示すように単純です。
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
<title></title>
<h:outputStylesheet library="#{facesContext.viewRoot.locale}/default" name="css/rafa.css"/>
<h:outputScript library="#{facesContext.viewRoot.locale}/default" name="rafa.js"/>
</h:head>
<h:body>
<f:view locale="#{localeBean.mylocale}">
<div style="width:100%; text-align:center">
<h:form>
<h:commandButton value="Rafa at Roland Garros" action="#{localeBean.changeLocale('fr')}"/>
<h:commandButton value="Rafa at Wimbledon" action="#{localeBean.changeLocale('en')}"/>
<h:commandButton value="Rafa at US Open" action="#{localeBean.changeLocale('us')}"/>
<h:commandButton value="Rafa at Australian Open" action="#{localeBean.changeLocale('au')}"/>
</h:form>
</div>
<div style="width:100%; text-align:center">
<!--<h:graphicImage library="#{facesContext.viewRoot.locale}/default" name="img/rafa.png"/> -->
<h:graphicImage value="#{resource[facesContext.viewRoot.locale+='/default:img/rafa.png']}"/>
</div>
</f:view>
</h:body>
</html>
とともに
@Named
@RequestScoped
public class LocaleBean {
private String mylocale = "fr";
// getters & setters
}
内部使用で使用Glassfish 4.1.1 Application Server
していますが、Mojarra 2.2.12
rendered HTML
は-
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="j_idt2">
<title></title>
<script type="text/javascript" src="/glassfish-ee/javax.faces.resource/rafa.js.xhtml?ln=fr/default&v=1_01_2">
</script><link type="text/css" rel="stylesheet" href="/glassfish-ee/javax.faces.resource/css/rafa.css.xhtml?ln=fr/default&v=1_0" />
</head>
<body>
<div style="width:100%; text-align:center">
<form id="j_idt8" name="j_idt8" method="post" action="/glassfish-ee/ch5/ch5_12/index.xhtml" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="j_idt8" value="j_idt8" />
<input type="submit" name="j_idt8:j_idt9" value="Rafa at Roland Garros" />
<input type="submit" name="j_idt8:j_idt10" value="Rafa at Wimbledon" />
<input type="submit" name="j_idt8:j_idt11" value="Rafa at US Open" />
<input type="submit" name="j_idt8:j_idt12" value="Rafa at Australian Open" />
<input type="hidden" name="javax.faces.ViewState" id="j_id1:javax.faces.ViewState:0" value="---somevalue---" autocomplete="off" />
</form>
</div>
<div style="width:100%; text-align:center">
<!--<h:graphicImage library="fr/default" name="img/rafa.png"/> -->
<img src="/glassfish-ee/javax.faces.resource/img/rafa.png.xhtml?ln=fr/default&v=1_0" />
</div>
</body>
</html>
レンダリングされた html で関心のある相対 URL-
http://localhost:8080/glassfish-ee/javax.faces.resource/rafa.js.xhtml?ln=fr/default&v=1_01_2
http://localhost:8080/glassfish-ee/javax.faces.resource/css/rafa.css.xhtml?ln=fr/default&v=1_0
http://localhost:8080/glassfish-ee/javax.faces.resource/img/rafa.png.xhtml?ln=fr/default&v=1_0
コンソールでは、これを取得します-
2016-06-08T20:54:52.672+0530|WARNING: JSF1064: Unable to find or serve resource, rafa.js, from library, fr/default.
2016-06-08T20:54:52.673+0530|WARNING: JSF1064: Unable to find or serve resource, css/rafa.css, from library, fr/default.
2016-06-08T20:54:52.717+0530|WARNING: JSF1064: Unable to find or serve resource, img/rafa.png, from library, fr/default.
2016-06-08T20:54:57.570+0530|WARNING: JSF1064: Unable to find or serve resource, css/rafa.css, from library, fr/default.
2016-06-08T20:56:05.587+0530|WARNING: JSF1064: Unable to find or serve resource, img/rafa.png, from library, fr/default.
2016-06-08T20:56:09.542+0530|WARNING: JSF1064: Unable to find or serve resource, img/rafa.png, from library, fr/default.
Google chromeのコンソールタブに表示されます-
最後に、どこが間違っているのでしょうか?
提案してください。
以下に提案された回答の助けを借りて、変更を加えた後、
エントリーで~
javax.faces.resource.localePrefix=fr
GET リクエストでページにアクセスすると、上に添付された構造のように1_2.js
示されているファイル内の次のエントリにより、アラートがポップアップ表示されます。selected
alert("J'ai gagné Roland Garros ...(resources/fr/1_0/css/js/rafa.js/1_2.js)");
locale
目的のを押して を変更した後でも、同じアラートがポップアップ表示されますcommand button
。
なんで?さらに何をする必要がありますか?前もって感謝します。