简体   繁体   中英

Using Locale Variants in JSF application for different environments

We have a JSF application which is deployed in 4 different versions for 4 different business brands it serves. Currently we have a separate code base for each brand and we copy and paste changes from one master brand's code base to the other brands code repositories when changes are made.

I'm trying to move to just having one single code base for all brands served.

We have the text used in the application in a resource property file and all the labels and text in the XHTML templates come from that.

My plan is to have a separate property file for each brand and switch between them using the Locale variant code. All four brands with be en_AU with a variant after ie:

  • en_AU_brandA
  • en_AU_brandB
  • en_AU_brandC
  • en_AU_brandD

Is this an appropriate way to do what I'm trying to do? Also is it possible to select which variant is to be used by the XHTML templates from the Java code at run time? I'm planning to use a case switch statement that determines which variant to use based on the server name.

You can set it programatically like this:

FacesContext.getCurrentInstance().getViewRoot().setLocale(locale);

Setting it via a bean in the xhtml:

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

Other ways are described here

Using the variant in the Locale can be a good way to switch for the different companys. Otherwise you have to do this programtically as well. But i would not recommend it if there is no other reason.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM