yegor256
yegor256

Reputation: 105083

How to detect client locale in JSF application?

How can I use ServletRequest.getLocale() in JSF application, when Servlet is absent in my code and is provided by JSF implementation? I'm trying to use ServletContextListener, but is it possible to reach ServletRequest from ServletContextEvent?

Anyway, what is the correct approach?

Upvotes: 3

Views: 5577

Answers (2)

Aravind Yarram
Aravind Yarram

Reputation: 80186

The correct way in my opinion is to provide the links on your home page for various locales your application needs to support. This is less intrusive for the end user. Otherwise the end user has to keep changing the locales browser specific way. Also different browsers send the locale different ways to the server which is also problematic depending on your usecase.

I strongly suggest you go through this tutorial.

Upvotes: 1

Zeemee
Zeemee

Reputation: 10714

FacesContext.getCurrentInstance().getExternalContext().getRequestLocale();

?

Upvotes: 10

Related Questions