From a1ecc54e818410bf5a16446fbbed3a6244bb177c Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Mon, 4 Apr 2016 18:47:31 +0200 Subject: [PATCH] Continued with localization support: - added form template for localization support (still static, maybe can be output over bean's method?) - added missing methods (not classical getter/setter) --- .../localization/PizzaLocalizationSessionBean.java | 11 +++++++++++ .../PizzaLocalizationSessionController.java | 14 ++++++++++++++ web/WEB-INF/templates/base.tpl | 1 + .../templates/generic/locale_selection_box.tpl | 14 ++++++++++++++ 4 files changed, 40 insertions(+) create mode 100644 web/WEB-INF/templates/generic/locale_selection_box.tpl diff --git a/src/java/org/mxchange/pizzaapplication/beans/localization/PizzaLocalizationSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/localization/PizzaLocalizationSessionBean.java index b8fb5cde..1e98b41e 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/localization/PizzaLocalizationSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/localization/PizzaLocalizationSessionBean.java @@ -45,6 +45,17 @@ public class PizzaLocalizationSessionBean extends BaseDatabaseBean implements Pi */ private Locale locale; + @Override + public String getLanguage () { + return this.getLocale().getLanguage(); + } + + @Override + public void setLanguage (final String language) { + this.setLocale(new Locale(language)); + FacesContext.getCurrentInstance().getViewRoot().setLocale(this.getLocale()); + } + @Override public Locale getLocale () { return this.locale; diff --git a/src/java/org/mxchange/pizzaapplication/beans/localization/PizzaLocalizationSessionController.java b/src/java/org/mxchange/pizzaapplication/beans/localization/PizzaLocalizationSessionController.java index e4c98139..430923d0 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/localization/PizzaLocalizationSessionController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/localization/PizzaLocalizationSessionController.java @@ -40,4 +40,18 @@ public interface PizzaLocalizationSessionController extends Serializable { */ void setLocale (final Locale locale); + /** + * Getter for language code + *

+ * @return Language code + */ + String getLanguage (); + + /** + * Setter for language code + *

+ * @param language Language code + */ + void setLanguage (final String language); + } diff --git a/web/WEB-INF/templates/base.tpl b/web/WEB-INF/templates/base.tpl index 5c7d9cbe..f1dae8a4 100644 --- a/web/WEB-INF/templates/base.tpl +++ b/web/WEB-INF/templates/base.tpl @@ -37,6 +37,7 @@