On 11/26/05, Laurie Harper <[EMAIL PROTECTED]> wrote:
>
> Craig McClanahan wrote:
> > In my localized apps, I bury that sort of thing inside the getter method
> for
> > the SelectItems list.  You can figure out what Locale you need to
> localize
> > for, for the current request, by calling:
> >
> >     FacesContext.getCurrentInstance().getViewRoot().getLocale()
> >
> > with per-Locale caching to prevent needless regeneration of an
> appropriate
> > list or array.  Saves a lot of time having to explain what <c:forEach>
> does
> > to a graphic designer.
>
> True, but how do I get the localization bundle loaded in the page?
> Actually, now I think about it I suppose it's part of the component
> tree, so it ought to be possible to dig it out somehow. Is there an easy
> way to do that?


Using the following tag:

    <f:loadBundle var="messages" basename="com.mycompany.mypackage.MyBundle
"/>

exposes the contents of the named resource bundle as a Map in request scope
under the specified key.  Now you can bind to it ... for example, to create
the localized label for the username field on a login screen, you might say:

    <h:outputText value="#{messages['usename.prompt']}"/>

where "username.prompt" is the message key.

Craig



L.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to