From: Roland Häder Date: Sun, 24 Sep 2017 12:18:44 +0000 (+0200) Subject: Please cherry-pick: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=eacdf6b11fcf437c20a54e0cfa0a892d07fab360;p=jfinancials-war.git Please cherry-pick: - the general resource bundle are now loaded (in BaseBean) 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 --- diff --git a/src/java/org/mxchange/jfinancials/beans/BaseFinancialsBean.java b/src/java/org/mxchange/jfinancials/beans/BaseFinancialsBean.java index 3b03fa6e..97348929 100644 --- a/src/java/org/mxchange/jfinancials/beans/BaseFinancialsBean.java +++ b/src/java/org/mxchange/jfinancials/beans/BaseFinancialsBean.java @@ -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; } } diff --git a/src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebRequestHelperBean.java b/src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebRequestHelperBean.java index db9384a1..923036a5 100644 --- a/src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebRequestHelperBean.java +++ b/src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebRequestHelperBean.java @@ -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. + *

+ * @param branchOffice Branch office instance + *

+ * @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. + *

+ * @param contact Contact instance + *

+ * @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 diff --git a/src/java/org/mxchange/localization/bundle_de_DE.properties b/src/java/org/mxchange/localization/bundle_de_DE.properties index 24a7af19..a6ff377c 100644 --- a/src/java/org/mxchange/localization/bundle_de_DE.properties +++ b/src/java/org/mxchange/localization/bundle_de_DE.properties @@ -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: diff --git a/src/java/org/mxchange/localization/bundle_en_US.properties b/src/java/org/mxchange/localization/bundle_en_US.properties index d94c15cf..d6d65f44 100644 --- a/src/java/org/mxchange/localization/bundle_en_US.properties +++ b/src/java/org/mxchange/localization/bundle_en_US.properties @@ -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: diff --git a/web/WEB-INF/templates/admin/branch_offices/admin_form_branch_offices_data.tpl b/web/WEB-INF/templates/admin/branch_offices/admin_form_branch_offices_data.tpl index e798ed35..567e1a0d 100644 --- a/web/WEB-INF/templates/admin/branch_offices/admin_form_branch_offices_data.tpl +++ b/web/WEB-INF/templates/admin/branch_offices/admin_form_branch_offices_data.tpl @@ -163,7 +163,7 @@

- +
diff --git a/web/WEB-INF/templates/base.tpl b/web/WEB-INF/templates/base.tpl index c5342cca..69b8dbaa 100644 --- a/web/WEB-INF/templates/base.tpl +++ b/web/WEB-INF/templates/base.tpl @@ -9,102 +9,102 @@ - - - - - - - - - - - - - - - - - - - - <h:outputText value="#{initParam['project_title']}" /> - <h:outputText value=" - " /> - <ui:insert name="title"> - <h:outputText value="Default title" /> - </ui:insert> - - - - - - - - - -
- - + + + + + + + + + + + + + + + + + + + <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> + + + + + + + -
- - + +
+ + + +
+ + +
+ + + +
+ +
+ + + +
+
- - - - - - - - - - - - - - -
- - -
-
- - -
+ + + + + -
- -
-
-
- + + + + + + +
+ + +
+ +
+ + +
+ +
+ +
+
+
+ +