]> git.mxchange.org Git - jfinancials-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>
Sun, 24 Sep 2017 12:18:44 +0000 (14:18 +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/jfinancials/beans/BaseFinancialsBean.java
src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebRequestHelperBean.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 3b03fa6e010a495e5d6844a95f63c4897b1d7807..97348929dd4e6a2854dbcc3cbce5d44db462f386 100644 (file)
@@ -27,6 +27,11 @@ import org.mxchange.jcoreee.bean.faces.BaseFacesBean;
  */
 public abstract class BaseFinancialsBean extends BaseFacesBean {
 
+       /**
+        * Loaded resource bundle ("cached")
+        */
+       private static ResourceBundle RESOURCE_BUNDLE;
+
        /**
         * Serial number
         */
@@ -42,11 +47,14 @@ public abstract class BaseFinancialsBean 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 db9384a1cffb7fb2b76efa3348b53f9d5c704754..923036a585b160548abbfb1f1bbce53a4aed5da8 100644 (file)
@@ -20,11 +20,13 @@ 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.jcontactsbusiness.model.branchoffice.BranchOffice;
 import org.mxchange.jfinancials.beans.BaseFinancialsBean;
 import org.mxchange.jfinancials.beans.contact.FinancialsAdminContactWebRequestController;
 import org.mxchange.jfinancials.beans.phone.FinancialsAdminPhoneWebRequestController;
@@ -454,6 +456,58 @@ public class FinancialsWebRequestHelperBean extends BaseFinancialsBean implement
                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 24a7af1954a44c1918cc06313edfa7804c3d66bf..a6ff377c205c6ede94da9f79042d4baf3c23a0fd 100644 (file)
@@ -961,3 +961,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 d94c15cfef44846c39ed775da85f670e96463d09..d6d65f444d969b284fadc3f42d1ea44b481d6bcc 100644 (file)
@@ -905,3 +905,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>