]> git.mxchange.org Git - jjobs-war.git/blob - src/java/org/mxchange/jjobs/beans/localization/JobsLocalizationSessionBean.java
change license to AGPLv3
[jjobs-war.git] / src / java / org / mxchange / jjobs / beans / localization / JobsLocalizationSessionBean.java
1 /*
2  * Copyright (C) 2016 Roland Haeder
3  *
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.
8  *
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.
13  *
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/>.
16  */
17 package org.mxchange.jjobs.beans.localization;
18
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;
25
26 /**
27  * A session bean for handling localization/internationalization changes. This
28  * class is based on an example at [1] from mkyong.
29  * <p>
30  * 1: http://www.mkyong.com/jsf2/jsf-2-internationalization-example/
31  * <p>
32  * @author Roland Haeder<roland@mxchange.org>
33  */
34 @Named ("localization")
35 @SessionScoped
36 public class JobsLocalizationSessionBean extends BaseDatabaseBean implements LocalizationSessionController {
37
38         /**
39          * Serial number
40          */
41         private static final long serialVersionUID = 1_867_671_657_629_601_528L;
42
43         /**
44          * Current Locale
45          */
46         private Locale locale;
47
48         @Override
49         public Locale getLocale () {
50                 return this.locale;
51         }
52
53         @Override
54         public void setLocale (final Locale locale) {
55                 this.locale = locale;
56         }
57
58         /**
59          * Initializer for this bean
60          */
61         @PostConstruct
62         public void init () {
63                 // Create locale instance from context
64                 Locale loc = FacesContext.getCurrentInstance().getExternalContext().getRequestLocale();
65
66                 // Set it here
67                 this.setLocale(loc);
68         }
69
70 }