Templates 如何在ui:composition模板子级中使用f:loadBundle
我有一个基于模板的“test.xhtml”:Templates 如何在ui:composition模板子级中使用f:loadBundle,templates,jsf-2,facelets,Templates,Jsf 2,Facelets,我有一个基于模板的“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="/te
<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”,而不是预期的名称。
这个问题只有在我使用模板时才会出现。
我做错了什么?我明白了:
这是错误的。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>
我明白了:
这是错误的。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>