]> git.mxchange.org Git - jjobs-war.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Sun, 24 Sep 2017 12:18:44 +0000 (14:18 +0200)
committerRoland Häder <roland@mxchange.org>
Fri, 19 Jul 2019 22:26:22 +0000 (00:26 +0200)
- the general resource bundle are now loaded (in Base<Project>Bean) only once
  and then kept in static field
- f:view is now back expanded over whole view, maybe not needed?
- fixed mess of msg (general) and project (-specific) i18n strings
- added missing i18n strings
- added helper method renderBranchOffice() and renderContact() which will
  render branch office and contact data respectively for JSF views. If not set
  (null provided), an empty string is returned.

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jjobs/beans/BaseJobsBean.java
src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelperBean.java
src/java/org/mxchange/localization/bundle_de_DE.properties
src/java/org/mxchange/localization/bundle_en_US.properties
web/WEB-INF/templates/admin/branch_offices/admin_form_branch_offices_data.tpl
web/WEB-INF/templates/base.tpl

index 84a6187eec1409b896b0e07b498d5c2f721c579f..369842c4fb85ec5bd9723a41d555b7e0081ef768 100644 (file)
@@ -27,6 +27,11 @@ import org.mxchange.jcoreee.bean.faces.BaseFacesBean;
  */
 public abstract class BaseJobsBean extends BaseFacesBean {
 
+       /**
+        * Loaded resource bundle ("cached")
+        */
+       private static ResourceBundle RESOURCE_BUNDLE;
+
        /**
         * Serial number
         */
@@ -42,11 +47,14 @@ public abstract class BaseJobsBean extends BaseFacesBean {
 
        @Override
        protected ResourceBundle loadResourceBundle (final Locale locale) {
-               // Load resource bundle, so it will be loaded from this JAR
-               ResourceBundle bundle = ResourceBundle.getBundle("org.mxchange.localization.bundle", locale);
+               // Is the instance there?
+               if (null == RESOURCE_BUNDLE) {
+                       // Load resource bundle, so it will be loaded from this JAR
+                       RESOURCE_BUNDLE = ResourceBundle.getBundle("org.mxchange.localization.bundle", locale);
+               }
 
-               // Return it
-               return bundle;
+               // Return cache instance
+               return RESOURCE_BUNDLE;
        }
 
 }
index 335e524722b7309aedaf42dce96ee6d9aac35478..ddeca5176ba6753db9ae215553e5302214ee4099 100644 (file)
@@ -20,12 +20,15 @@ import java.text.MessageFormat;
 import javax.enterprise.context.RequestScoped;
 import javax.enterprise.event.Event;
 import javax.enterprise.inject.Any;
+import javax.faces.context.FacesContext;
 import javax.inject.Inject;
 import javax.inject.Named;
 import org.mxchange.jcontacts.events.contact.created.CreatedContactEvent;
 import org.mxchange.jcontacts.events.contact.created.ObservableCreatedContactEvent;
 import org.mxchange.jcontacts.model.contact.Contact;
 import org.mxchange.jjobs.beans.BaseJobsBean;
+import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
+import org.mxchange.jjobs.beans.BaseJobsBean;
 import org.mxchange.jjobs.beans.contact.JobsAdminContactWebRequestController;
 import org.mxchange.jjobs.beans.phone.JobsAdminPhoneWebRequestController;
 import org.mxchange.jjobs.beans.user.JobsAdminUserWebRequestController;
@@ -454,6 +457,58 @@ public class JobsWebRequestHelperBean extends BaseJobsBean implements JobsWebReq
                this.userCreatedEvent.fire(new CreatedUserEvent(this.getUser()));
        }
 
+       /**
+        * Returns the branch office's full address. If null is provided, an empty
+        * string is returned.
+        * <p>
+        * @param branchOffice Branch office instance
+        * <p>
+        * @return Branch office's address
+        */
+       public String renderBranchOffice (final BranchOffice branchOffice) {
+               // Default is empty string, so let's get started
+               final StringBuilder sb = new StringBuilder(30);
+
+               // Is a branch office instance given?
+               if (branchOffice instanceof BranchOffice) {
+                       // Yes, then append all data
+                       sb.append(", ");
+                       sb.append(branchOffice.getBranchStreet());
+                       sb.append(" ");
+                       sb.append(branchOffice.getBranchHouseNumber());
+                       sb.append(", ");
+                       sb.append(branchOffice.getBranchCountry().getCountryCode());
+                       sb.append(" ");
+                       sb.append(branchOffice.getBranchZipCode());
+                       sb.append(branchOffice.getBranchCity());
+               }
+
+               // Return it
+               return sb.toString();
+       }
+
+       /**
+        * Returns the contact's personal title, family name and name. If null is
+        * provided, an empty string is returned.
+        * <p>
+        * @param contact Contact instance
+        * <p>
+        * @return Contact's name
+        */
+       public String renderContact (final Contact contact) {
+               // Default is empty string, so let's get started
+               final StringBuilder sb = new StringBuilder(20);
+
+               // Is contact set?
+               if (contact instanceof Contact) {
+                       // Then create name
+                       sb.append(String.format(FacesContext.getCurrentInstance().getViewRoot().getLocale(), "{0} {1}, {2}", this.getMessageFromBundle(contact.getContactPersonalTitle().getMessageKey()), contact.getContactFamilyName(), contact.getContactFirstName())); //NOI18N
+               }
+
+               // Return it
+               return sb.toString();
+       }
+
        /**
         * Set's all given contact's phone instances: land-line, mobile and
         * faxNumber
index f2f21b01716d7ce3a03beb51a01adeac9ded68e6..353fef5837b49aa547105604f23c65a383444a8f 100644 (file)
@@ -983,3 +983,7 @@ PAYMENT_TYPE_CREDIT_CARD=Kreditkarte
 PAYMENT_TYPE_DEBIT_CARD=Kundenkarte
 PAYMENT_TYPE_PREPAYMENT=Vorkasse
 PAYMENT_TYPE_INVOICE=Auf Rechnung
+#@TODO Please fix German umlauts!
+ADMIN_SELECT_SELLER_EMPLOYEE=Verkaeufer auswaehlen:
+#@TODO Please fix German umlauts!
+LOGIN_SELECT_SELLER_EMPLOYEE=Bitte waehlen Sie einen Verkaeufer aus:
index bc3b4a241a46c2ac10efbf1b501767b5c13eb44f..3d33c195b5842a034dc34d7816d0c7131aff7056 100644 (file)
@@ -929,3 +929,5 @@ PAYMENT_TYPE_CREDIT_CARD=Credit card
 PAYMENT_TYPE_DEBIT_CARD=Debit card
 PAYMENT_TYPE_PREPAYMENT=Prepayment
 PAYMENT_TYPE_INVOICE=Per invoice
+ADMIN_SELECT_SELLER_EMPLOYEE=Choose seller:
+LOGIN_SELECT_SELLER_EMPLOYEE=Please choose a seller:
index e798ed35224eab902c08f6c75ddeefd388d64ca1..567e1a0d226067b921b7dbf286220e5a497e8d40 100644 (file)
 
                        <h:panelGroup styleClass="table-row" layout="block">
                                <div class="table-left-medium">
-                                       <p:outputLabel for="branchNumber" value="#{project.ADMIN_ENTER_BRANCH_OFFICE_NUMBER}" />
+                                       <p:outputLabel for="branchNumber" value="#{msg.ADMIN_ENTER_BRANCH_OFFICE_NUMBER}" />
                                </div>
 
                                <div class="table-right-medium">
index c5342ccadb264016c3c7b85ef9aa4225975a370b..69b8dbaaef9100d969c49b910de4653a27ffe654 100644 (file)
        <h:doctype rootElement="html" public="-//W3C//DTD XHTML 1.0 Transitional//EN" system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
 
        <html lang="#{localizationController.locale.language}" xml:lang="#{localizationController.locale.language}" xmlns="http://www.w3.org/1999/xhtml">
-               <f:view locale="#{localizationController.locale}" contentType="text/html" />
-
-               <h:head>
-                       <f:facet name="first">
-                               <ui:insert name="metadata" />
-
-                               <meta http-equiv="X-UA-Compatible" content="IE=edge" />
-                               <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-                               <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
-                               <meta name="apple-mobile-web-app-capable" content="yes" />
-                       </f:facet>
-
-                       <f:loadBundle var="msg" basename="org.mxchange.localization.bundle" />
-                       <f:loadBundle var="project" basename="org.mxchange.localization.project" />
-
-                       <h:outputStylesheet name="/css/default.css" />
-                       <h:outputStylesheet name="/css/layout.css" />
-
-                       <title>
-                               <h:outputText value="#{initParam['project_title']}" />
-                               <h:outputText value=" - " />
-                               <ui:insert name="title">
-                                       <h:outputText value="Default title" />
-                               </ui:insert>
-                       </title>
-               </h:head>
-
-               <h:body>
-                       <pm:header>
-                               <div id="page-header">
-                                       <h1>
-                                               <h:outputText value="#{initParam['project_title']} - " />
-
-                                               <ui:insert name="title">
-                                                       <h:outputText value="Default title" />
-                                               </ui:insert>
-                                       </h1>
-                               </div>
-                       </pm:header>
-
-                       <h:panelGroup id="menu-content-wrapper" layout="block">
-                               <div id="left-menu-container">
-                                       <ui:insert name="menu">
-                                               <h:outputText value="Default menu" />
+               <f:view locale="#{localizationController.locale}" contentType="text/html">
+                       <h:head>
+                               <f:facet name="first">
+                                       <ui:insert name="metadata" />
+
+                                       <meta http-equiv="X-UA-Compatible" content="IE=edge" />
+                                       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+                                       <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
+                                       <meta name="apple-mobile-web-app-capable" content="yes" />
+                               </f:facet>
+
+                               <f:loadBundle var="msg" basename="org.mxchange.localization.bundle" />
+                               <f:loadBundle var="project" basename="org.mxchange.localization.project" />
+
+                               <h:outputStylesheet name="/css/default.css" />
+                               <h:outputStylesheet name="/css/layout.css" />
+
+                               <title>
+                                       <h:outputText value="#{initParam['project_title']}" />
+                                       <h:outputText value=" - " />
+                                       <ui:insert name="title">
+                                               <h:outputText value="Default title" />
                                        </ui:insert>
-
-                                       <ui:include src="/WEB-INF/templates/widgets/locale_change_widget.tpl" />
-                               </div>
-
-                               <h:panelGroup id="content_outer" class="content-container" layout="block">
-                                       <div id="content-header">
-                                               <ui:insert name="content_header">
-                                                       <h:outputText value="Default content header" />
-                                               </ui:insert>
+                               </title>
+                       </h:head>
+
+                       <h:body>
+                               <pm:header>
+                                       <div id="page-header">
+                                               <h1>
+                                                       <h:outputText value="#{initParam['project_title']} - " />
+
+                                                       <ui:insert name="title">
+                                                               <h:outputText value="Default title" />
+                                                       </ui:insert>
+                                               </h1>
                                        </div>
+                               </pm:header>
 
-                                       <div id="content">
-                                               <ui:insert name="content">
-                                                       <h:outputText value="Default content" />
+                               <h:panelGroup id="menu-content-wrapper" layout="block">
+                                       <div id="left-menu-container">
+                                               <ui:insert name="menu">
+                                                       <h:outputText value="Default menu" />
                                                </ui:insert>
+
+                                               <ui:include src="/WEB-INF/templates/widgets/locale_change_widget.tpl" />
                                        </div>
+
+                                       <h:panelGroup id="content_outer" class="content-container" layout="block">
+                                               <div id="content-header">
+                                                       <ui:insert name="content_header">
+                                                               <h:outputText value="Default content header" />
+                                                       </ui:insert>
+                                               </div>
+
+                                               <div id="content">
+                                                       <ui:insert name="content">
+                                                               <h:outputText value="Default content" />
+                                                       </ui:insert>
+                                               </div>
+                                       </h:panelGroup>
                                </h:panelGroup>
-                       </h:panelGroup>
-
-                       <h:panelGroup id="page-footer" layout="block">
-                               <ui:insert name="footer">
-                                       <h:outputText value="Default footer" />
-                               </ui:insert>
-                       </h:panelGroup>
-
-                       <h:panelGroup styleClass="error-container" layout="block">
-                               <p:growl autoUpdate="true" showDetail="true" sticky="true" />
-
-                               <p:ajaxExceptionHandler type="javax.faces.application.ViewExpiredException"
-                                                                               update="exceptionDialog"
-                                                                               onexception="PF('exceptionDialog').show();" />
-
-                               <p:dialog id="exceptionDialog" closable="true" closeOnEscape="true" header="Exception '#{pfExceptionHandler.type}' occured!" widgetVar="exceptionDialog"
-                                                 height="500px">
-                                       <div class="para">
-                                               <h:outputText value="#{msg.EXCEPTION_MESSAGE}:" />
-                                               <h:outputText value="#{pfExceptionHandler.message}" />
-                                       </div>
 
-                                       <div class="para">
-                                               <h:outputText value="#{msg.EXCEPTION_STACK_TRACE}:" />
-                                               <h:outputText value="#{pfExceptionHandler.formattedStackTrace}" escape="false" />
-                                       </div>
+                               <h:panelGroup id="page-footer" layout="block">
+                                       <ui:insert name="footer">
+                                               <h:outputText value="Default footer" />
+                                       </ui:insert>
+                               </h:panelGroup>
 
-                                       <div class="para">
-                                               <p:button onclick="window.location.href = document.location.href;"
-                                                                 value="#{msg.RELOAD_PAGE}"
-                                                                 rendered="#{pfExceptionHandler.type == 'javax.faces.application.ViewExpiredException'}" />
-                                       </div>
-                               </p:dialog>
-                       </h:panelGroup>
-               </h:body>
+                               <h:panelGroup styleClass="error-container" layout="block">
+                                       <p:growl autoUpdate="true" showDetail="true" sticky="true" />
+
+                                       <p:ajaxExceptionHandler type="javax.faces.application.ViewExpiredException"
+                                                                                       update="exceptionDialog"
+                                                                                       onexception="PF('exceptionDialog').show();" />
+
+                                       <p:dialog id="exceptionDialog" closable="true" closeOnEscape="true" header="Exception '#{pfExceptionHandler.type}' occured!" widgetVar="exceptionDialog"
+                                                         height="500px">
+                                               <div class="para">
+                                                       <h:outputText value="#{msg.EXCEPTION_MESSAGE}:" />
+                                                       <h:outputText value="#{pfExceptionHandler.message}" />
+                                               </div>
+
+                                               <div class="para">
+                                                       <h:outputText value="#{msg.EXCEPTION_STACK_TRACE}:" />
+                                                       <h:outputText value="#{pfExceptionHandler.formattedStackTrace}" escape="false" />
+                                               </div>
+
+                                               <div class="para">
+                                                       <p:button onclick="window.location.href = document.location.href;"
+                                                                         value="#{msg.RELOAD_PAGE}"
+                                                                         rendered="#{pfExceptionHandler.type == 'javax.faces.application.ViewExpiredException'}" />
+                                               </div>
+                                       </p:dialog>
+                               </h:panelGroup>
+                       </h:body>
+               </f:view>
        </html>
 </ui:composition>