Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3752228
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:12:41+00:00 2026-05-19T09:12:41+00:00

I implemented internationalization into my JSF app as described here . But I encountered

  • 0

I implemented internationalization into my JSF app as described here.

But I encountered a problem: When I change the locale all the texts on my page change. But then if I click a navigation-link to get to another page the locale jumps back to standard locale!

I think I miss something here. So I provide my code below and hope you can help:

LocaleBean.java:

    @ManagedBean(name="locale")
    @SessionScoped
    public class LocaleBean {

    private Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale();

    public Locale getLocale() {
        return locale;
    }

    public void setLanguage(String language) {
        locale = new Locale(language);
        FacesContext.getCurrentInstance().getViewRoot().setLocale(locale);
    }

    public String getLanguage() {
        return locale.getLanguage();
    }
    }

JSF Part (it’s part of my template):

    <h:outputText value=" #{text['common.language']}: " /> 
        <h:selectOneMenu value="#{locale.language}" onchange="submit()">
            <f:selectItem itemValue="de" itemLabel="Deutsch" />
            <f:selectItem itemValue="en" itemLabel="English" />
        </h:selectOneMenu>

faces-config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<faces-config
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
    version="2.0">
     <application>
           <locale-config>
                <default-locale>de</default-locale>
                <supported-locale>en</supported-locale>
           </locale-config>
       <resource-bundle>
        <base-name>org.dhbw.stg.wwi2008c.mopro.ui.text</base-name>
        <var>text</var>
       </resource-bundle>
     </application>
</faces-config>

I then Text.java from the tutorial and only changed bundle-path.

Here my directory:

If something important is missing ask for it please.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T09:12:42+00:00Added an answer on May 19, 2026 at 9:12 am

    FacesContext is request scoped instance. so your value would be set for that particular request only.

    add on xhtml

    <f:view locale="#{locale.locale}">
    

    OR:

    Register a view Handler
    in faces-config.xml

     <application>
               ...
           <view-handler>com.yourcompany.MyLocaleViewHandler</view-handler> 
    

    and

    public class MyLocaleViewHandler extends ViewHandler {
    
        private final ViewHandler base;
    
    
        @Override
        public Locale calculateLocale(FacesContext context) {
          //fetch the session scoped bean and return the
          LocaleBean bean = (LocaleBean ) context.getExternalContext().getRequest().getSession().getAttribute("locale");//this line is not tested.
          return locale;
        }
          //other stuff..
    
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I implemented the replaceAll() method with matcher, which replaces all punctuations with . But
I implemented in my app MFMessageComposeViewController for send sms. It works well, but I
I'm trying to implement internationalization in JSF 2. I've tried many solutions, but I'm
I'm going to implement my strings with internationalization in my Android app. I have
I implemented a select from-to pair of lists on a page and added add/remove
I implemented a drop down navigation menus in my blog, but it's not working
I implemented simple server-client chat in Java. Here the source for the server: public
I implemented 6 months ago in our web application site(Asp.Net) a page where you
I implemented a quick search in my application. But when I turned the screen,
Ive implemented ray picking using min3d and some code I found online but when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.