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=13c1bb339440573e5ab36c9c04faef4a30f858b9;p=jjobs-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/jjobs/beans/BaseJobsBean.java b/src/java/org/mxchange/jjobs/beans/BaseJobsBean.java index 84a6187e..369842c4 100644 --- a/src/java/org/mxchange/jjobs/beans/BaseJobsBean.java +++ b/src/java/org/mxchange/jjobs/beans/BaseJobsBean.java @@ -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; } } diff --git a/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelperBean.java b/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelperBean.java index 335e5247..ddeca517 100644 --- a/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelperBean.java +++ b/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelperBean.java @@ -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. + *

+ * @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 f2f21b01..353fef58 100644 --- a/src/java/org/mxchange/localization/bundle_de_DE.properties +++ b/src/java/org/mxchange/localization/bundle_de_DE.properties @@ -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: diff --git a/src/java/org/mxchange/localization/bundle_en_US.properties b/src/java/org/mxchange/localization/bundle_en_US.properties index bc3b4a24..3d33c195 100644 --- a/src/java/org/mxchange/localization/bundle_en_US.properties +++ b/src/java/org/mxchange/localization/bundle_en_US.properties @@ -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: 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> + + + + + + + -
- - + +
+ + + +
+ + +
+ + + +
+ +
+ + + +
+
- - - - - - - - - - - - - - -
- - -
-
- - -
+ + + + + -
- -
-
-
- + + + + + + +
+ + +
+ +
+ + +
+ +
+ +
+
+
+ +