1

テンプレートに基づいた「test.xhtml」があります。

    <ui:composition xmlns="http://www.w3.org/1999/xhtml"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:h="http://java.sun.com/jsf/html"
        template="/templates/BasicTemplate.xhtml">
        <f:loadBundle basename="label" var="label" />
...
    <h:commandButton value="#{label.buttonname}" ...></h:commandButton>
...

ファイル「label.properties」は WEB-INF/classes にあります。しかし、ブラウザにロードすると、代替はありませんでしたが、予想される名前の代わりに、ボタンに「label.buttonname」が付けられました。この問題は、テンプレートで使用した場合にのみ発生します。私は何を間違っていますか?

4

1 に答える 1

1

わかりました: これは間違っています (!)。LoadBudle は、composition と define タグの間にあります。

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    template="/templates/BasicTemplate.xhtml">
    <f:loadBundle basename="label" var="label" /> <--- WRONG place!!!
    <ui:define name="content">
        <h:commandButton value="#{label.buttonname}" ...></h:commandButton>
    </ui:define>

これは問題ありません:

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    template="/templates/BasicTemplate.xhtml">
    <ui:define name="content">
        <f:loadBundle basename="label" var="label" />
        <h:commandButton value="#{label.buttonname}" ...></h:commandButton>
    </ui:define>
于 2012-12-16T13:20:02.493 に答える