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

index 30dc3135742fb902e799b8d7ce4170161668bfc4..21e97bbcba323f64bb6159317ef96ce564990595 100644 (file)
@@ -45,6 +45,17 @@ public class JobsLocalizationSessionBean extends BaseDatabaseBean implements Job
         */
        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 73f6e92fbb02f1ab53209405820b89c739cd5173..b2818729084ea722dc57cc3bd164cf8d77e55ef9 100644 (file)
@@ -40,4 +40,18 @@ public interface JobsLocalizationSessionController 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 1507b407003e4b0dbc215abca4f08a6b79d5ef86..7f318f2c435474d343f102f83c7203cf1be4ea4a 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>