I used for internationalization the JSF configuration, and I have a list of countries from the class Locale
in <p:selectOneMenu>
, but
I am facing a problem of duplicate values of the countries list in <p:selectOneMenu>
when I change the language of the page
How can I correct this problem?
private List<String> countriesList = new ArrayList<String>();
public void setCountriesList(List<String> countriesList) {
this.countriesList = countriesList;
}
public List<String> getCountriesList() {
String[] locales = Locale.getISOCountries();
for (String countryCode : locales) {
Locale obj = new Locale("", countryCode);
countriesList.add(obj.getDisplayCountry(Locale.ENGLISH));
}
Collections.sort(countriesList);
return countriesList;
}