]> git.mxchange.org Git - jfinancials-war.git/commitdiff
Continued with localization support:
authorRoland Haeder <roland@mxchange.org>
Mon, 4 Apr 2016 16:47:37 +0000 (18:47 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 4 Apr 2016 16:47:37 +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/addressbook/beans/localization/AddressbookLocalizationSessionBean.java
src/java/org/mxchange/addressbook/beans/localization/AddressbookLocalizationSessionController.java
web/WEB-INF/templates/base.tpl
web/WEB-INF/templates/generic/locale_selection_box.tpl [new file with mode: 0644]

index dd587438a57e900d2937db39f33fe03829d941b5..9316575d1c24a57cc26e5c2eb7e25d72279817db 100644 (file)
@@ -45,6 +45,17 @@ public class AddressbookLocalizationSessionBean extends BaseDatabaseBean impleme
         */
        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 642a7f3e40feb22929c5db1e374b0637e89cecb4..81bda8f1becd24284f7900494ce081101f510056 100644 (file)
@@ -40,4 +40,18 @@ public interface AddressbookLocalizationSessionController 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 2e862b4c1b229221107a957b75eeb09694b27d20..a180370d1096b8536f80e39ce843aa50c3aa5189 100644 (file)
@@ -30,6 +30,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>