]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
Continued with localization support:
authorRoland Haeder <roland@mxchange.org>
Mon, 4 Apr 2016 16:47:31 +0000 (18:47 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 4 Apr 2016 16:47:31 +0000 (18:47 +0200)
- added form template for localization support (still static, maybe can be output over bean's method?)
- added missing methods (not classical getter/setter)

src/java/org/mxchange/pizzaapplication/beans/localization/PizzaLocalizationSessionBean.java
src/java/org/mxchange/pizzaapplication/beans/localization/PizzaLocalizationSessionController.java
web/WEB-INF/templates/base.tpl
web/WEB-INF/templates/generic/locale_selection_box.tpl [new file with mode: 0644]

index b8fb5cde08be99cfd1515247fb8586f884990dd6..1e98b41e54d119e82c568eb2ab8b029eac22f1eb 100644 (file)
@@ -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;
index e4c9813997940da74902cf7957e00164511f8201..430923d07865db36fa624d9a4d9b1c0e56c79912 100644 (file)
@@ -40,4 +40,18 @@ public interface PizzaLocalizationSessionController extends Serializable {
         */
        void setLocale (final Locale locale);
 
+       /**
+        * Getter for language code
+        * <p>
+        * @return Language code
+        */
+       String getLanguage ();
+
+       /**
+        * Setter for language code
+        * <p>
+        * @param language Language code
+        */
+       void setLanguage (final String language);
+
 }
index 5c7d9cbe56eaa65e935657af2c39a50fe5fa6139..f1dae8a40ac961a4c0104167e4518f8b4a766093 100644 (file)
@@ -37,6 +37,7 @@
                <div id="menu_content">
                        <div id="left">
                                <ui:insert name="menu">Default menu</ui:insert>
+                               <ui:include src="/WEB-INF/templates/generic/locale_selection_box.tpl" />
                        </div>
 
                        <div id="content_outer" class="left_content">
diff --git a/web/WEB-INF/templates/generic/locale_selection_box.tpl b/web/WEB-INF/templates/generic/locale_selection_box.tpl
new file mode 100644 (file)
index 0000000..0dc84df
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ui:composition
+       xmlns="http://www.w3.org/1999/xhtml"
+       xmlns:f="http://java.sun.com/jsf/core"
+       xmlns:h="http://java.sun.com/jsf/html"
+       xmlns:ui="http://java.sun.com/jsf/facelets">
+
+       <h:form id="locale_selection">
+               <h:selectOneMenu value="#{localization.locale.language}" onchange="submit()">
+                       <f:selectItem itemValue="de" itemLabel="Deutsch" />
+                       <f:selectItem itemValue="en" itemLabel="English" />
+               </h:selectOneMenu>
+       </h:form>
+</ui:composition>