5

Using f:loadbundle when using jsp as the view description language for an JSF application is pretty straight forward.

I want to know where to put this f:loadbundle when i am using facelets

Sreeram
  • 3,160
  • 6
  • 33
  • 44

1 Answers1

5

Except from the way the taglibs are declared, it's really not different from JSP.

<!DOCTYPE html>
<html lang="en"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets">
    <f:loadBundle basename="com.example.i18n.text" var="text" />
    <head>
        <title>Facelets page</title>
    </head>
    <body>
        <h:outputText value="#{text['some.key']}" />
    </body>  
</html>

This also applies to all other tags/components. The only major difference is that you need to declare the taglib in a XML namespace instead of an old fashioned JSP <%@taglib %> thingy.

sryll
  • 114
  • 8
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thanks for the response BalusC.Can i declare outside the ui:composition tags? – Sreeram Sep 23 '11 at 15:04
  • No. Anything outside `` is ignored. Just declare it inside. – BalusC Sep 23 '11 at 15:15
  • So it also belongs outside `f:head`? See my `base.tpl` at this question: https://stackoverflow.com/questions/45537018/doctype-not-rendered-in-jsf-master-template – Roland Apr 02 '18 at 22:30
  • Still for a `f:viewParam id="fooId" name="fooId" required="true" requiredMessage="#{bundle.PARAMETER_FOO_ID_IS_REQUIRED}"` my `p:message for="fooId"` remains with no message shown but tag is rendered (means I see an empty alert box). – Roland Apr 02 '18 at 22:33