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 7645803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:02:17+00:00 2026-05-31T10:02:17+00:00

I have a combobox where users can select an available language. The application contains

  • 0

I have a combobox where users can select an available language. The application contains properties files for each language.
In the resources section of the page the resource bundle is calculates according to a language tag ( DE, EN … ) in a user config document.

Is there any easy way to change the language in the onChange event according to the value of the combobox? I thought of context.setProperty(???).
Any suggestion?

  • 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-31T10:02:19+00:00Added an answer on May 31, 2026 at 10:02 am

    To implement this application wide you could use a phase listener. In this example, the locale to use is stored in a sessionScope variable named “Language”.

    Just add a combobox to your XPage(s) containing all allowed locales.

    <xp:comboBox id="comboBox1" value="#{sessionScope.Language}">
        <xp:selectItem itemLabel="Chinese" itemValue="zh"></xp:selectItem>
        <xp:selectItem itemLabel="German" itemValue="de"></xp:selectItem>
        <xp:selectItem itemLabel="Turkish" itemValue="tr"></xp:selectItem>
        <xp:eventHandler event="onchange" submit="true" refreshMode="complete" />
    </xp:comboBox>
    

    Then you have to use a phase listener like this one:

    package ch.hasselba.xpages.jsf.core;
    
    import javax.faces.context.FacesContext;
    import javax.faces.application.Application;
    import javax.faces.event.PhaseEvent;
    import javax.faces.event.PhaseId;
    import javax.faces.event.PhaseListener;
    import javax.faces.component.UIViewRoot;
    import java.util.Locale;
    import java.util.Map;
    
    public class LocalizationSetter implements PhaseListener {
    
        private static final long serialVersionUID = -1L;
        private static final String scopeVarName = "Language";
        private static final String scopeName = "sessionScope"; 
    
        public void afterPhase(PhaseEvent event) {}
    
        public void beforePhase(PhaseEvent event) {
            FacesContext facesContext = event.getFacesContext();
            UIViewRoot view = facesContext.getViewRoot();
            view.setLocale( getLanguage(facesContext) ) ;
        }
    
        public PhaseId getPhaseId() {
            return PhaseId.RENDER_RESPONSE;
        }
    
        private Locale getLanguage( FacesContext facesContext ){
            try{
                Application app = facesContext.getApplication();
                Object obj = app.getVariableResolver().resolveVariable(facesContext, scopeName );
                Object lang = ((Map) obj).get( scopeVarName );
                if( lang != null ){
                    return new Locale((String) lang);
                }
            }catch(Exception e){}
    
            return Locale.getDefault();
        }
    }
    

    You can add lookups / etc. to access the user profiles in the “getLanguag()” method.

    Hope this helps
    Sven

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a listbox that you can select users in. To the left of
I have a combobox and it's editable. So the user can select an item,
I have a combobox on a web form. The user can select a single
I have a combobox where the user can select a particular year (populated by
I have a combobox bound to a collection, so the user can select one
I have a user control with a combobox, and so I can edit its
How can you make a ComboBox where the user can select null ? If
In XAML I have a combobox defined as: <ComboBox x:Name=UsernameComboBox ItemsSource={Binding Users} DisplayMemberPath=Username SelectedItem={Binding
I have a winform containing a DropDown combobox, where the user can enter a
I have a databound dgv that contains combobox columns. When the user selects an

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.