2 * Copyright (C) 2016 Roland Haeder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License as
6 * published by the Free Software Foundation, either version 3 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Affero General Public License for more details.
14 * You should have received a copy of the GNU Affero General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.jjobs.beans.localization;
19 import java.util.Locale;
20 import javax.annotation.PostConstruct;
21 import javax.faces.bean.SessionScoped;
22 import javax.faces.context.FacesContext;
23 import javax.inject.Named;
24 import org.mxchange.jcoreee.database.BaseDatabaseBean;
27 * A session bean for handling localization/internationalization changes. This
28 * class is based on an example at [1] from mkyong.
30 * 1: http://www.mkyong.com/jsf2/jsf-2-internationalization-example/
32 * @author Roland Haeder<roland@mxchange.org>
34 @Named ("localization")
36 public class JobsLocalizationSessionBean extends BaseDatabaseBean implements JobsLocalizationSessionController {
41 private static final long serialVersionUID = 1_867_671_657_629_601_528L;
46 private Locale locale;
49 public String getLanguage () {
50 return this.getLocale().getLanguage();
54 public void setLanguage (final String language) {
55 this.setLocale(new Locale(language));
56 FacesContext.getCurrentInstance().getViewRoot().setLocale(this.getLocale());
60 public Locale getLocale () {
65 public void setLocale (final Locale locale) {
70 * Initializer for this bean
74 // Create locale instance from context
75 Locale loc = FacesContext.getCurrentInstance().getExternalContext().getRequestLocale();