Alex004
Alex004

Reputation: 785

How to use f:loadBundle in ui:composition template child

I have a "test.xhtml", based on a template:

    <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>
...

The file "label.properties" is located in WEB-INF/classes. But when I load it in my browser, there was no replacement, but instead of the expected name I got "label.buttonname" upon my button. This problem only appears if I use it with templating. What am I doing wrong?

Upvotes: 1

Views: 679

Answers (1)

Alex004
Alex004

Reputation: 785

I got it: This is WRONG (!). LoadBudle is between composition and define tag.

<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>

This is fine:

<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>

Upvotes: 1

Related Questions