From: Roland Häder Date: Fri, 30 Mar 2018 17:36:50 +0000 (+0200) Subject: Please cherry-pick: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=11ccdf2a4fbc77a385aeb38e09334bf229f96c80;p=jfinancials-war.git Please cherry-pick: - data output by a p:dataTable with pagination, filtering and sorting cannot come from a request-scoped bean as each AJAX request will reset the filteredValue-referenced bean property to null which leads to an empty table. - better is to have a separate backing bean on view-scoped which holds both lists, the full ("all") list and filtered list (which are the items that have passed the filter). - also had to update converters and validators - finally, no need for javax.faces.STATE_SAVING_METHOD=client anymore! yeah! - rewrote menu system (admin at least, guest and user login is following) to a menu-bar-based system which saves a lot space and is a more modern approach - added filter for not caching xhtml (JSF view) requests Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsBasicDataWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsBasicDataWebRequestBean.java index 230195e6..89f4a2f7 100644 --- a/src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsBasicDataWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsBasicDataWebRequestBean.java @@ -16,25 +16,11 @@ */ package org.mxchange.jfinancials.beans.business.basicdata; -import fish.payara.cdi.jsr107.impl.NamedCache; -import java.text.MessageFormat; -import java.util.Comparator; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Objects; -import javax.annotation.PostConstruct; -import javax.cache.Cache; import javax.ejb.EJB; import javax.enterprise.context.RequestScoped; -import javax.enterprise.event.Observes; import javax.inject.Inject; import javax.inject.Named; -import org.mxchange.jcontactsbusiness.events.basicdata.added.ObservableAdminAddedBusinessBasicDataEvent; -import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicDataNotFoundException; import org.mxchange.jcontactsbusiness.model.basicdata.AdminBasicCompanyDataSessionBeanRemote; -import org.mxchange.jcontactsbusiness.model.basicdata.BasicCompanyDataSessionBeanRemote; -import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; import org.mxchange.jcountry.model.data.Country; import org.mxchange.jfinancials.beans.BaseFinancialsBean; import org.mxchange.jfinancials.beans.user.login.FinancialsUserLoginWebSessionController; @@ -44,7 +30,7 @@ import org.mxchange.jfinancials.beans.user.login.FinancialsUserLoginWebSessionCo *

* @author Roland Häder */ -@Named ("basicCompanyDataController") +@Named ("basicDataController") @RequestScoped public class FinancialsBasicDataWebRequestBean extends BaseFinancialsBean implements FinancialsBasicDataWebRequestController { @@ -59,24 +45,6 @@ public class FinancialsBasicDataWebRequestBean extends BaseFinancialsBean implem @EJB (lookup = "java:global/jfinancials-ejb/adminBasicCompanyData!org.mxchange.jcontactsbusiness.model.basicdata.AdminBasicCompanyDataSessionBeanRemote", description = "A stateless session bean for administrative purposes.") private AdminBasicCompanyDataSessionBeanRemote adminBasicCompanyDataBean; - /** - * List of all basic company data - */ - private final List allBasicData; - - /** - * A list of all registered companies (globally) - */ - @Inject - @NamedCache (cacheName = "basicDataCache") - private Cache basicDataCache; - - /** - * EJB for general basic business data purposes - */ - @EJB (lookup = "java:global/jfinancials-ejb/basicCompanyData!org.mxchange.jcontactsbusiness.model.basicdata.BasicCompanyDataSessionBeanRemote", description = "A stateless session bean for general purposes.") - private BasicCompanyDataSessionBeanRemote businessDataBean; - /** * Comments for this company */ @@ -107,11 +75,6 @@ public class FinancialsBasicDataWebRequestBean extends BaseFinancialsBean implem */ private Long faxNumber; - /** - * List of filtered basic company data - */ - private List filteredBasicCompanyData; - /** * Area code for land-line number */ @@ -139,73 +102,6 @@ public class FinancialsBasicDataWebRequestBean extends BaseFinancialsBean implem public FinancialsBasicDataWebRequestBean () { // Call super constructor super(); - - // Init list - this.allBasicData = new LinkedList<>(); - } - - /** - * Observers events being fired when an administrator has added company - * basic data. - *

- * @param event Event being fired - */ - public void afterAdminAddedBasicCompanyDataEvent (@Observes final ObservableAdminAddedBusinessBasicDataEvent event) { - // Is the parameter valid? - if (null == event) { - // Throw NPE - throw new NullPointerException("event is null"); //NOI18N - } else if (event.getBasicData() == null) { - // Throw NPE again - throw new NullPointerException("event.basicData is null"); //NOI18N - } else if (event.getBasicData().getBasicDataId() == null) { - // Throw NPE again - throw new NullPointerException("event.basicData.basicDataId is null"); //NOI18N - } else if (event.getBasicData().getBasicDataId() < 1) { - // Throw IAE - throw new IllegalArgumentException(MessageFormat.format("event.basicData.basicDataId={0} is invalid", event.getBasicData().getBasicDataId())); //NOI18N - } else if (event.getBasicData().getCompanyName() == null) { - // Throw NPE again - throw new NullPointerException("event.basicData.companyName is null"); //NOI18N - } else if (event.getBasicData().getCompanyName().isEmpty()) { - // Throw IAE again - throw new IllegalArgumentException("event.basicData.companyName is empty"); //NOI18N - } - - // Add it to list - this.basicDataCache.put(event.getBasicData().getBasicDataId(), event.getBasicData()); - this.allBasicData.add(event.getBasicData()); - } - - /** - * Getter for a list of all business contacts - *

- * @return A list of all business contacts - */ - @SuppressWarnings ("ReturnOfCollectionOrArrayField") - public List allBasicData () { - return this.allBasicData; - } - - @Override - public BasicData findBasicDataById (final Long basicDataId) throws BasicDataNotFoundException { - // Validate parameter - if (null == basicDataId) { - // Throw NPE - throw new NullPointerException("basicDataId is null"); //NOI18N - } else if (basicDataId < 1) { - // Throw IAE - throw new IllegalArgumentException(MessageFormat.format("basicDataId={0} is invalid", basicDataId)); //NOI18N - } else if (!this.basicDataCache.containsKey(basicDataId)) { - // Not found - throw new BasicDataNotFoundException(basicDataId); - } - - // Get it from cache - final BasicData basicData = this.basicDataCache.get(basicDataId); - - // Return it - return basicData; } /** @@ -316,26 +212,6 @@ public class FinancialsBasicDataWebRequestBean extends BaseFinancialsBean implem this.faxNumber = faxNumber; } - /** - * Getter for filtered basic company data - *

- * @return Filtered basic company data - */ - @SuppressWarnings ("ReturnOfCollectionOrArrayField") - public List getFilteredBasicCompanyData () { - return this.filteredBasicCompanyData; - } - - /** - * Setter for filtered basic company data - *

- * @param filteredBasicCompanyData Filtered basic company data - */ - @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter") - public void setFilteredBasicCompanyData (final List filteredBasicCompanyData) { - this.filteredBasicCompanyData = filteredBasicCompanyData; - } - /** * Getter for land-line number's area code *

@@ -390,103 +266,6 @@ public class FinancialsBasicDataWebRequestBean extends BaseFinancialsBean implem this.landLineNumber = landLineNumber; } - /** - * Initializer method - */ - @PostConstruct - public void initializeList () { - // Is cache there? - if (!this.basicDataCache.iterator().hasNext()) { - // Get whole list - final List basicDatas = this.businessDataBean.allBusinessBasicData(); - - // Add all - for (final BasicData basicData : basicDatas) { - // Add it to cache - this.basicDataCache.put(basicData.getBasicDataId(), basicData); - } - } - - // Is cache there and list is not full? - if ((this.allBasicData.isEmpty()) && (this.basicDataCache.iterator().hasNext())) { - // Get iterator - final Iterator> iterator = this.basicDataCache.iterator(); - - // Build up list - while (iterator.hasNext()) { - // GEt next element - final Cache.Entry next = iterator.next(); - - // Add to list - this.allBasicData.add(next.getValue()); - } - - // Sort list - this.allBasicData.sort(new Comparator() { - @Override - public int compare (final BasicData o1, final BasicData o2) { - return o1.getBasicDataId() > o2.getBasicDataId() ? 1 : o1.getBasicDataId() < o2.getBasicDataId() ? -1 : 0; - } - }); - } - } - - @Override - public Boolean isCompanyNameUsed (final String companyName) { - // Validate parameter - if (null == companyName) { - // Throw NPE - throw new NullPointerException("companyName is null"); //NOI18N - } else if (companyName.isEmpty()) { - // Throw IAE - throw new IllegalArgumentException("companyName is empty"); //NOI18N - } - - // Default is not found - boolean isFound = false; - - // Check all entries - for (final BasicData basicData : this.allBasicData()) { - // Is same company name? - if (Objects.equals(basicData.getCompanyName(), companyName)) { - // Found it - isFound = true; - break; - } - } - - // Return flag - return isFound; - } - - @Override - public Boolean isEmailAddressRegistered (final String emailAddress) { - // Validate parameter - if (null == emailAddress) { - // Throw NPE - throw new NullPointerException("emailAddress is null"); //NOI18N - } else if (emailAddress.isEmpty()) { - // Throw IAE - throw new IllegalArgumentException("emailAddress is empty"); //NOI18N - } - - // Default is not found - boolean isFound = false; - - // Check all entries - for (final BasicData basicData : this.allBasicData()) { - // Is email address used? - if (Objects.equals(basicData.getCompanyEmailAddress(), emailAddress)) { - // Found it - isFound = true; - break; - } - } - - // Return flag - return isFound; - } - /** * Clears this bean */ diff --git a/src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsBasicDataWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsBasicDataWebRequestController.java index 8822ce0c..cb224bb5 100644 --- a/src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsBasicDataWebRequestController.java +++ b/src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsBasicDataWebRequestController.java @@ -17,8 +17,6 @@ package org.mxchange.jfinancials.beans.business.basicdata; import java.io.Serializable; -import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicDataNotFoundException; -import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; /** * An interface for session-scoped financial controller @@ -27,36 +25,4 @@ import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; */ public interface FinancialsBasicDataWebRequestController extends Serializable { - /** - * Checks if given email address is already registered by other basic - * company data - *

- * @param emailAddress Email address - *

- * @return Whether the email address has been already registered - */ - Boolean isEmailAddressRegistered (final String emailAddress); - - /** - * Retrieves a single business data entity for given id number or throws a - * proper exception if not found. - *

- * @param basicDataId Company basic data id to lookup - *

- * @return Business contact instance - *

- * @throws BasicDataNotFoundException If the id number could not be looked - * up and solved into an entity - */ - BasicData findBasicDataById (final Long basicDataId) throws BasicDataNotFoundException; - - /** - * Checks whether given company name already exists - *

- * @param companyName Company name to check - *

- * @return Whether the company name exists - */ - Boolean isCompanyNameUsed (final String companyName); - } diff --git a/src/java/org/mxchange/jfinancials/beans/business/basicdata/list/FinancialsBasicDataListWebViewBean.java b/src/java/org/mxchange/jfinancials/beans/business/basicdata/list/FinancialsBasicDataListWebViewBean.java new file mode 100644 index 00000000..fc91ae9c --- /dev/null +++ b/src/java/org/mxchange/jfinancials/beans/business/basicdata/list/FinancialsBasicDataListWebViewBean.java @@ -0,0 +1,271 @@ +/* + * Copyright (C) 2017, 2018 Free Software Foundation + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.mxchange.jfinancials.beans.business.basicdata.list; + +import fish.payara.cdi.jsr107.impl.NamedCache; +import java.text.MessageFormat; +import java.util.Comparator; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Objects; +import javax.annotation.PostConstruct; +import javax.cache.Cache; +import javax.ejb.EJB; +import javax.enterprise.event.Observes; +import javax.faces.view.ViewScoped; +import javax.inject.Inject; +import javax.inject.Named; +import org.mxchange.jcontactsbusiness.events.basicdata.added.ObservableAdminAddedBusinessBasicDataEvent; +import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicDataNotFoundException; +import org.mxchange.jcontactsbusiness.model.basicdata.BasicCompanyDataSessionBeanRemote; +import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; +import org.mxchange.jfinancials.beans.BaseFinancialsBean; + +/** + * A view-scoped bean for product lists + *

+ * @author Roland Haeder + */ +@Named ("basicDataListController") +@ViewScoped +public class FinancialsBasicDataListWebViewBean extends BaseFinancialsBean implements FinancialsBasicDataListWebViewController { + + /** + * Serial number + */ + private static final long serialVersionUID = 34_869_872_672_645L; + + /** + * List of all basic company data + */ + private final List allBasicData; + + /** + * EJB for general basic business data purposes + */ + @EJB (lookup = "java:global/jfinancials-ejb/basicCompanyData!org.mxchange.jcontactsbusiness.model.basicdata.BasicCompanyDataSessionBeanRemote", description = "A stateless session bean for general purposes.") + private BasicCompanyDataSessionBeanRemote basicDataBean; + + /** + * A list of all registered companies (globally) + */ + @Inject + @NamedCache (cacheName = "basicDataCache") + private transient Cache basicDataCache; + + /** + * List of filtered basic company data + */ + private List filteredBasicData; + + /** + * Default constructor + */ + public FinancialsBasicDataListWebViewBean () { + // Call super constructor + super(); + + // Init list + this.allBasicData = new LinkedList<>(); + } + + /** + * Observers events being fired when an administrator has added company + * basic data. + *

+ * @param event Event being fired + */ + public void afterAdminAddedBasicCompanyDataEvent (@Observes final ObservableAdminAddedBusinessBasicDataEvent event) { + // Is the parameter valid? + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); //NOI18N + } else if (event.getBasicData() == null) { + // Throw NPE again + throw new NullPointerException("event.basicData is null"); //NOI18N + } else if (event.getBasicData().getBasicDataId() == null) { + // Throw NPE again + throw new NullPointerException("event.basicData.basicDataId is null"); //NOI18N + } else if (event.getBasicData().getBasicDataId() < 1) { + // Throw IAE + throw new IllegalArgumentException(MessageFormat.format("event.basicData.basicDataId={0} is invalid", event.getBasicData().getBasicDataId())); //NOI18N + } else if (event.getBasicData().getCompanyName() == null) { + // Throw NPE again + throw new NullPointerException("event.basicData.companyName is null"); //NOI18N + } else if (event.getBasicData().getCompanyName().isEmpty()) { + // Throw IAE again + throw new IllegalArgumentException("event.basicData.companyName is empty"); //NOI18N + } + + // Add it to list + this.basicDataCache.put(event.getBasicData().getBasicDataId(), event.getBasicData()); + this.getAllBasicData().add(event.getBasicData()); + } + + @Override + public BasicData findBasicDataById (final Long basicDataId) throws BasicDataNotFoundException { + // Validate parameter + if (null == basicDataId) { + // Throw NPE + throw new NullPointerException("basicDataId is null"); //NOI18N + } else if (basicDataId < 1) { + // Throw IAE + throw new IllegalArgumentException(MessageFormat.format("basicDataId={0} is invalid", basicDataId)); //NOI18N + } else if (!this.basicDataCache.containsKey(basicDataId)) { + // Not found + throw new BasicDataNotFoundException(basicDataId); + } + + // Get it from cache + final BasicData basicData = this.basicDataCache.get(basicDataId); + + // Return it + return basicData; + } + + /** + * Getter for a list of all business contacts + *

+ * @return A list of all business contacts + */ + @SuppressWarnings ("ReturnOfCollectionOrArrayField") + public List getAllBasicData () { + return this.allBasicData; + } + + /** + * Getter for filtered basic company data + *

+ * @return Filtered basic company data + */ + @SuppressWarnings ("ReturnOfCollectionOrArrayField") + public List getFilteredBasicData () { + return this.filteredBasicData; + } + + /** + * Setter for filtered basic company data + *

+ * @param filteredBasicData Filtered basic company data + */ + @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter") + public void setFilteredBasicData (final List filteredBasicData) { + this.filteredBasicData = filteredBasicData; + } + + /** + * Initializer method + */ + @PostConstruct + public void initializeList () { + // Is cache there? + if (!this.basicDataCache.iterator().hasNext()) { + // Get whole list + final List basicDatas = this.basicDataBean.allBusinessBasicData(); + + // Add all + for (final BasicData basicData : basicDatas) { + // Add it to cache + this.basicDataCache.put(basicData.getBasicDataId(), basicData); + } + } + + // Is cache there and list is not full? + if ((this.getAllBasicData().isEmpty()) && (this.basicDataCache.iterator().hasNext())) { + // Get iterator + final Iterator> iterator = this.basicDataCache.iterator(); + + // Build up list + while (iterator.hasNext()) { + // GEt next element + final Cache.Entry next = iterator.next(); + + // Add to list + this.getAllBasicData().add(next.getValue()); + } + + // Sort list + this.getAllBasicData().sort(new Comparator() { + @Override + public int compare (final BasicData o1, final BasicData o2) { + return o1.getBasicDataId() > o2.getBasicDataId() ? 1 : o1.getBasicDataId() < o2.getBasicDataId() ? -1 : 0; + } + }); + + // Set full list + this.setFilteredBasicData(this.getAllBasicData()); + } + } + + @Override + public Boolean isCompanyNameUsed (final String companyName) { + // Validate parameter + if (null == companyName) { + // Throw NPE + throw new NullPointerException("companyName is null"); //NOI18N + } else if (companyName.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("companyName is empty"); //NOI18N + } + + // Default is not found + boolean isFound = false; + + // Check all entries + for (final BasicData basicData : this.getAllBasicData()) { + // Is same company name? + if (Objects.equals(basicData.getCompanyName(), companyName)) { + // Found it + isFound = true; + break; + } + } + + // Return flag + return isFound; + } + + @Override + public Boolean isEmailAddressRegistered (final String emailAddress) { + // Validate parameter + if (null == emailAddress) { + // Throw NPE + throw new NullPointerException("emailAddress is null"); //NOI18N + } else if (emailAddress.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("emailAddress is empty"); //NOI18N + } + + // Default is not found + boolean isFound = false; + + // Check all entries + for (final BasicData basicData : this.getAllBasicData()) { + // Is email address used? + if (Objects.equals(basicData.getCompanyEmailAddress(), emailAddress)) { + // Found it + isFound = true; + break; + } + } + + // Return flag + return isFound; + } + +} diff --git a/src/java/org/mxchange/jfinancials/beans/business/basicdata/list/FinancialsBasicDataListWebViewController.java b/src/java/org/mxchange/jfinancials/beans/business/basicdata/list/FinancialsBasicDataListWebViewController.java new file mode 100644 index 00000000..c1063717 --- /dev/null +++ b/src/java/org/mxchange/jfinancials/beans/business/basicdata/list/FinancialsBasicDataListWebViewController.java @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2018 Free Software Foundation + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.mxchange.jfinancials.beans.business.basicdata.list; + +import java.io.Serializable; +import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicDataNotFoundException; +import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; + +/** + * An interface of basic data list backing beans + *

+ * @author Roland Häder + */ +public interface FinancialsBasicDataListWebViewController extends Serializable { + + /** + * Retrieves a single business data entity for given id number or throws a + * proper exception if not found. + *

+ * @param basicDataId Company basic data id to lookup + *

+ * @return Business contact instance + *

+ * @throws BasicDataNotFoundException If the id number could not be looked + * up and solved into an entity + */ + BasicData findBasicDataById (final Long basicDataId) throws BasicDataNotFoundException; + + /** + * Checks if given email address is already registered by other basic + * company data + *

+ * @param emailAddress Email address + *

+ * @return Whether the email address has been already registered + */ + Boolean isEmailAddressRegistered (final String emailAddress); + + /** + * Checks whether given company name already exists + *

+ * @param companyName Company name to check + *

+ * @return Whether the company name exists + */ + Boolean isCompanyNameUsed (final String companyName); + +} diff --git a/src/java/org/mxchange/jfinancials/beans/data/FinancialsDataWebApplicationBean.java b/src/java/org/mxchange/jfinancials/beans/data/FinancialsDataWebApplicationBean.java index 7c40f4a1..18470d2d 100644 --- a/src/java/org/mxchange/jfinancials/beans/data/FinancialsDataWebApplicationBean.java +++ b/src/java/org/mxchange/jfinancials/beans/data/FinancialsDataWebApplicationBean.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Roland Haeder + * Copyright (C) 2017, 2018 Free Software Foundation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as diff --git a/src/java/org/mxchange/jfinancials/converter/business/basicdata/FinancialsBasicCompanyDataConverter.java b/src/java/org/mxchange/jfinancials/converter/business/basicdata/FinancialsBasicCompanyDataConverter.java index b083696f..8138466b 100644 --- a/src/java/org/mxchange/jfinancials/converter/business/basicdata/FinancialsBasicCompanyDataConverter.java +++ b/src/java/org/mxchange/jfinancials/converter/business/basicdata/FinancialsBasicCompanyDataConverter.java @@ -24,8 +24,8 @@ import javax.faces.convert.ConverterException; import javax.faces.convert.FacesConverter; import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicDataNotFoundException; import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; -import org.mxchange.jfinancials.beans.business.basicdata.FinancialsBasicDataWebRequestBean; -import org.mxchange.jfinancials.beans.business.basicdata.FinancialsBasicDataWebRequestController; +import org.mxchange.jfinancials.beans.business.basicdata.list.FinancialsBasicDataListWebViewBean; +import org.mxchange.jfinancials.beans.business.basicdata.list.FinancialsBasicDataListWebViewController; /** * Converter for basic company data id <-> valid basic company data instance @@ -38,14 +38,14 @@ public class FinancialsBasicCompanyDataConverter implements Converter /** * Basic company data backing bean */ - private static FinancialsBasicDataWebRequestController BASIC_DATA_CONTROLLER; + private static FinancialsBasicDataListWebViewController BASIC_DATA_LIST_CONTROLLER; @Override public BasicData getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { // Is the instance there? - if (null == BASIC_DATA_CONTROLLER) { + if (null == BASIC_DATA_LIST_CONTROLLER) { // Get bean from CDI directly - BASIC_DATA_CONTROLLER = CDI.current().select(FinancialsBasicDataWebRequestBean.class).get(); + BASIC_DATA_LIST_CONTROLLER = CDI.current().select(FinancialsBasicDataListWebViewBean.class).get(); } // Is the value null or empty? @@ -65,7 +65,7 @@ public class FinancialsBasicCompanyDataConverter implements Converter final Long basicDataId = Long.valueOf(submittedValue); // Try to get user instance from it - basicData = BASIC_DATA_CONTROLLER.findBasicDataById(basicDataId); + basicData = BASIC_DATA_LIST_CONTROLLER.findBasicDataById(basicDataId); } catch (final NumberFormatException ex) { // Throw again throw new ConverterException(ex); diff --git a/src/java/org/mxchange/jfinancials/filter/FinancialsNoCacheFilter.java b/src/java/org/mxchange/jfinancials/filter/FinancialsNoCacheFilter.java new file mode 100644 index 00000000..044da91a --- /dev/null +++ b/src/java/org/mxchange/jfinancials/filter/FinancialsNoCacheFilter.java @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2018 Free Software Foundation + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.mxchange.jfinancials.filter; + +import java.io.IOException; +import javax.faces.application.ResourceHandler; +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.annotation.WebFilter; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * A filter for no-caching of JSF requests send from client. This class was + * taken from stackoverflow.com at + * https://stackoverflow.com/questions/3642919/javax-faces-application-viewexpiredexception-view-could-not-be-restored + * and was slightly expanded with "final" keyword and comments + *

+ * @author Bauke "BalusC" Scholz + * @author Roland Häder + */ +@WebFilter (servletNames = {"Faces Servlet"}) +public class FinancialsNoCacheFilter implements Filter { + + @Override + public void destroy () { + System.out.println("destroy!"); + } + + @Override + public void doFilter (final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException { + // Cast parameter + final HttpServletRequest req = (HttpServletRequest) request; + final HttpServletResponse res = (HttpServletResponse) response; + + // Is the request URI not starting with resource identifier? + if (!req.getRequestURI().startsWith(req.getContextPath() + ResourceHandler.RESOURCE_IDENTIFIER)) { + res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); //NOI18N + res.setHeader("Pragma", "no-cache"); // //NOI18N + res.setDateHeader("Expires", 0); // //NOI18N + } + + // Continue filtering + chain.doFilter(request, response); + } + + @Override + public void init (final FilterConfig filterConfig) throws ServletException { + System.out.println("init!"); + } + +} diff --git a/src/java/org/mxchange/jfinancials/validator/business/basicdata/FinancialsBasicDataCompanyNameValidator.java b/src/java/org/mxchange/jfinancials/validator/business/basicdata/FinancialsBasicDataCompanyNameValidator.java index 6044ea03..7c1511fc 100644 --- a/src/java/org/mxchange/jfinancials/validator/business/basicdata/FinancialsBasicDataCompanyNameValidator.java +++ b/src/java/org/mxchange/jfinancials/validator/business/basicdata/FinancialsBasicDataCompanyNameValidator.java @@ -24,8 +24,8 @@ import javax.faces.context.FacesContext; import javax.faces.validator.FacesValidator; import javax.faces.validator.ValidatorException; import org.mxchange.jcoreee.validator.string.BaseStringValidator; -import org.mxchange.jfinancials.beans.business.basicdata.FinancialsBasicDataWebRequestBean; -import org.mxchange.jfinancials.beans.business.basicdata.FinancialsBasicDataWebRequestController; +import org.mxchange.jfinancials.beans.business.basicdata.list.FinancialsBasicDataListWebViewBean; +import org.mxchange.jfinancials.beans.business.basicdata.list.FinancialsBasicDataListWebViewController; /** * A validator for basic data company names @@ -38,7 +38,7 @@ public class FinancialsBasicDataCompanyNameValidator extends BaseStringValidator /** * Business basic data backing bean */ - private static FinancialsBasicDataWebRequestController BASIC_DATA_CONTROLLER; + private static FinancialsBasicDataListWebViewController BASIC_DATA_LIST_CONTROLLER; /** * Serial number @@ -48,9 +48,9 @@ public class FinancialsBasicDataCompanyNameValidator extends BaseStringValidator @Override public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException { // Is the instance there? - if (null == BASIC_DATA_CONTROLLER) { + if (null == BASIC_DATA_LIST_CONTROLLER) { // Get bean from CDI directly - BASIC_DATA_CONTROLLER = CDI.current().select(FinancialsBasicDataWebRequestBean.class).get(); + BASIC_DATA_LIST_CONTROLLER = CDI.current().select(FinancialsBasicDataListWebViewBean.class).get(); } // All accepted, required fields @@ -81,7 +81,7 @@ public class FinancialsBasicDataCompanyNameValidator extends BaseStringValidator } // Check if name is already used - final Boolean nameExists = BASIC_DATA_CONTROLLER.isCompanyNameUsed(companyName); + final Boolean nameExists = BASIC_DATA_LIST_CONTROLLER.isCompanyNameUsed(companyName); // Is the user id valid? if ((!nameExists) && (checkExisting)) { diff --git a/src/java/org/mxchange/jfinancials/validator/emailaddress/basicdata/FinancialsBasicDataEmailAddressValidator.java b/src/java/org/mxchange/jfinancials/validator/emailaddress/basicdata/FinancialsBasicDataEmailAddressValidator.java index b42b24c5..cdf0c3a0 100644 --- a/src/java/org/mxchange/jfinancials/validator/emailaddress/basicdata/FinancialsBasicDataEmailAddressValidator.java +++ b/src/java/org/mxchange/jfinancials/validator/emailaddress/basicdata/FinancialsBasicDataEmailAddressValidator.java @@ -25,8 +25,8 @@ import javax.faces.context.FacesContext; import javax.faces.validator.FacesValidator; import javax.faces.validator.ValidatorException; import org.mxchange.jcoreee.validator.string.BaseStringValidator; -import org.mxchange.jfinancials.beans.business.basicdata.FinancialsBasicDataWebRequestBean; -import org.mxchange.jfinancials.beans.business.basicdata.FinancialsBasicDataWebRequestController; +import org.mxchange.jfinancials.beans.business.basicdata.list.FinancialsBasicDataListWebViewBean; +import org.mxchange.jfinancials.beans.business.basicdata.list.FinancialsBasicDataListWebViewController; /** * A validator for basic company data email address validation @@ -39,7 +39,7 @@ public class FinancialsBasicDataEmailAddressValidator extends BaseStringValidato /** * Branch office backing bean */ - private static FinancialsBasicDataWebRequestController BASIC_DATA_CONTROLLER; + private static FinancialsBasicDataListWebViewController BASIC_DATA_LIST_CONTROLLER; /** * Email pattern @@ -115,13 +115,13 @@ public class FinancialsBasicDataEmailAddressValidator extends BaseStringValidato final String clientId = component.getClientId(); // Is the instance there? - if (null == BASIC_DATA_CONTROLLER) { + if (null == BASIC_DATA_LIST_CONTROLLER) { // Get bean from CDI directly - BASIC_DATA_CONTROLLER = CDI.current().select(FinancialsBasicDataWebRequestBean.class).get(); + BASIC_DATA_LIST_CONTROLLER = CDI.current().select(FinancialsBasicDataListWebViewBean.class).get(); } // Is it registered? - final Boolean isRegistered = BASIC_DATA_CONTROLLER.isEmailAddressRegistered(emailAddress); + final Boolean isRegistered = BASIC_DATA_LIST_CONTROLLER.isEmailAddressRegistered(emailAddress); // Is the email address already registered? if ((!clientId.endsWith("resendEmailAddress")) && (isRegistered)) { //NOI18N diff --git a/src/java/org/mxchange/localization/generic_de_DE.properties b/src/java/org/mxchange/localization/generic_de_DE.properties index ceee7986..e7498fcb 100644 --- a/src/java/org/mxchange/localization/generic_de_DE.properties +++ b/src/java/org/mxchange/localization/generic_de_DE.properties @@ -238,7 +238,7 @@ PAGE_TITLE_ADMIN_EDIT_USER=Benuzteraccount editieren CONTENT_TITLE_ADMIN_EDIT_USER=\u00c4ndern von Benutzeraccounts: PAGE_TITLE_ADMIN_UNLOCK_USER=Entsperren von Benutzeraccounts CONTENT_TITLE_ADMIN_UNLOCK_USER=Entsperren von Benutzeraccounts: -ADMIN_MENU_USER_TITLE=Benutzerverwaltung +ADMIN_MENU_USER_TITLE=Benutzer #@TODO Please fix German umlauts! PAGE_TITLE_ADMIN_ADD_USER=Neues Benutzeraccount hinzufuegen CONTENT_TITLE_ADMIN_ADD_USER=Neues Benutzeraccount hinzufuegen: @@ -472,7 +472,7 @@ GUEST_CONFIRMATION_KEY_NOT_SET=Es wurde keine Best\u00e4tigungsschl\u00fcssel an GUEST_CONFIRM_USER_ACCOUNT_DONE_TITLE=Vielen Dank f\u00fcr die Best\u00e4tigung GUEST_USER_CONFIRM_ACCOUNT_DONE=Hallo {0} {1} {2}. Sie haben soeben Ihren Account best\u00e4tigt. Es ist eine Mail mit weiteren Details an Sie unterwegs. BUTTON_GUEST_CONFIRM_USER_ACCOUNT=Account best\u00e4tigen -ADMIN_MENU_CONTACT_TITLE=Kontaktdaten verwalten +ADMIN_MENU_CONTACT_TITLE=Kontaktdaten ADMIN_LINK_LIST_CONTACT=Kontaktdaten ADMIN_LINK_LIST_CONTACT_TITLE=Listet alle Kontaktdaten auf, egal wo her sie angelegt wurden. ADMIN_CONTACT_COUNTRY_CODE=L\u00e4ndercode: @@ -576,7 +576,7 @@ ERROR_BEAN_HELPER_USER_NOT_SET=Fehler: Instanz 'user' im Bean-Helper nicht geset ERROR_BEAN_HELPER_CONTACT_NOT_SET=Fehler: Instanz 'contact' im Bean-Helper nicht gesetzt. ERROR_BEAN_HELPER_MOBILE_NUMBER_NOT_SET=Fehler: Instanz 'mobile' in Bean-Helper nicht gesetzt. CONTENT_TITLE_ADMIN_LIST_CONTACT_MOBILE_NUMBER=Auflisten von Mobiltelefonnummern: -ADMIN_MENU_PHONE_NUMBERS_TITLE=Telefonnummern: +ADMIN_MENU_PHONE_NUMBERS_TITLE=Telefonnummern ADMIN_LINK_LIST_MOBILE_PHONE_NUMBERS=Handynummern ADMIN_LINK_LIST_MOBILE_PHONE_NUMBERS_TITLE=Alle Mobilfunknummern auflisten. ADMIN_SHOW_PHONE_CREATED=Telefoneintrag erstellt: @@ -1163,3 +1163,5 @@ ADMIN_LAND_LINE_NUMBER_REQUIRED=Bitte geben Sie die Rufnummer zur Festnetznummer ADMIN_FAX_AREA_CODE_REQUIRED=Bitte geben Sie die Vorwahlnummer zur Faxnummer ein. ADMIN_FAX_NUMBER_REQUIRED=Bitte geben Sie die Rufnummer zur Faxnummer ein. CHOICE_ALL=Alle/s +ENTER_KEYWORD=Stichwort eingeben ... +SEARCH_ALL_FIELDS=Alle Felder durchsuchen: diff --git a/src/java/org/mxchange/localization/generic_en_US.properties b/src/java/org/mxchange/localization/generic_en_US.properties index 6a6ac24b..e6c50760 100644 --- a/src/java/org/mxchange/localization/generic_en_US.properties +++ b/src/java/org/mxchange/localization/generic_en_US.properties @@ -218,7 +218,7 @@ PAGE_TITLE_ADMIN_EDIT_USER=Edit user accounts CONTENT_TITLE_ADMIN_EDIT_USER=Edit user accounts: PAGE_TITLE_ADMIN_UNLOCK_USER=Unlock user accounts CONTENT_TITLE_ADMIN_UNLOCK_USER=Unlock user accounts: -ADMIN_MENU_USER_TITLE=User management +ADMIN_MENU_USER_TITLE=Users PAGE_TITLE_ADMIN_ADD_USER=Add new user account CONTENT_TITLE_ADMIN_ADD_USER=Add new user account: TABLE_SUMMARY_ADMIN_LIST_USERS=Administration, list all users @@ -460,7 +460,7 @@ GUEST_CONFIRMATION_KEY_NOT_SET=No confirmation key was provided. Please check th GUEST_CONFIRM_USER_ACCOUNT_DONE_TITLE=Thank you for confirmation of your account GUEST_USER_CONFIRM_ACCOUNT_DONE=Hello {0} {1} {2}. You have successfully confirmed your account. An email with more details is on it's way to you. BUTTON_GUEST_CONFIRM_USER_ACCOUNT=Confirm account -ADMIN_MENU_CONTACT_TITLE=Manage contact data +ADMIN_MENU_CONTACT_TITLE=Contact data ADMIN_LINK_LIST_CONTACT=Contact data ADMIN_LINK_LIST_CONTACT_TITLE=Lists all contact data regardless where they was created. ADMIN_CONTACT_COUNTRY_CODE=Country code: @@ -561,7 +561,7 @@ ERROR_BEAN_HELPER_USER_NOT_SET=Error: Instance 'user' not set in bean helper. ERROR_BEAN_HELPER_CONTACT_NOT_SET=Error: Instance 'contact' not set in bean helper. ERROR_BEAN_HELPER_MOBILE_NUMBER_NOT_SET=Error: Instance 'mobile' in bean helper not set. CONTENT_TITLE_ADMIN_LIST_CONTACT_MOBILE_NUMBER=List mobile phone numbers: -ADMIN_MENU_PHONE_NUMBERS_TITLE=Phone numbers: +ADMIN_MENU_PHONE_NUMBERS_TITLE=Phone numbers ADMIN_LINK_LIST_MOBILE_PHONE_NUMBERS=Mobile numbers ADMIN_LINK_LIST_MOBILE_PHONE_NUMBERS_TITLE=List all mobile numbers. ADMIN_SHOW_PHONE_CREATED=Created: @@ -1051,3 +1051,5 @@ ADMIN_LAND_LINE_NUMBER_REQUIRED=Please enter caller number for land-line number. ADMIN_FAX_AREA_CODE_REQUIRED=Please enter an area-code for fax number. ADMIN_FAX_NUMBER_REQUIRED=Please enter caller number for fax number. CHOICE_ALL=All +ENTER_KEYWORD=Enter keyword ... +SEARCH_ALL_FIELDS=Search all fields: diff --git a/web/WEB-INF/templates/admin/admin_menu.tpl b/web/WEB-INF/templates/admin/admin_menu.tpl index b992069a..9310b72e 100644 --- a/web/WEB-INF/templates/admin/admin_menu.tpl +++ b/web/WEB-INF/templates/admin/admin_menu.tpl @@ -1,14 +1,13 @@ + > - + @@ -48,10 +47,12 @@ - + - + + + diff --git a/web/WEB-INF/templates/admin/branch_office/admin_form_branch_office_data.tpl b/web/WEB-INF/templates/admin/branch_office/admin_form_branch_office_data.tpl index 22ebd8a7..c8c5a4cf 100644 --- a/web/WEB-INF/templates/admin/branch_office/admin_form_branch_office_data.tpl +++ b/web/WEB-INF/templates/admin/branch_office/admin_form_branch_office_data.tpl @@ -23,7 +23,7 @@ > - + diff --git a/web/WEB-INF/templates/admin/department/admin_form_department_data.tpl b/web/WEB-INF/templates/admin/department/admin_form_department_data.tpl index bc7fb9c6..50ef8bad 100644 --- a/web/WEB-INF/templates/admin/department/admin_form_department_data.tpl +++ b/web/WEB-INF/templates/admin/department/admin_form_department_data.tpl @@ -30,7 +30,7 @@ > - + diff --git a/web/WEB-INF/templates/admin/employee/admin_form_employee_data.tpl b/web/WEB-INF/templates/admin/employee/admin_form_employee_data.tpl index e206995b..ca95d35b 100644 --- a/web/WEB-INF/templates/admin/employee/admin_form_employee_data.tpl +++ b/web/WEB-INF/templates/admin/employee/admin_form_employee_data.tpl @@ -23,7 +23,7 @@ > - + diff --git a/web/WEB-INF/templates/base.tpl b/web/WEB-INF/templates/base.tpl index 3c397ae5..a9da0c56 100644 --- a/web/WEB-INF/templates/base.tpl +++ b/web/WEB-INF/templates/base.tpl @@ -39,33 +39,37 @@ - - -

- - - - - -

- + + + +

+ + + + + +

+
+ + + + +
+
- - + - + - - - - + + @@ -85,29 +89,31 @@ - -
- - -
- -
- - -
- -
- -
-
+ + +
+ + +
+ +
+ + +
+ +
+ +
+
+
diff --git a/web/WEB-INF/templates/widgets/locale_change_widget.tpl b/web/WEB-INF/templates/widgets/locale_change_widget.tpl index e714b82d..5e75c095 100644 --- a/web/WEB-INF/templates/widgets/locale_change_widget.tpl +++ b/web/WEB-INF/templates/widgets/locale_change_widget.tpl @@ -7,15 +7,18 @@ xmlns:p="http://primefaces.org/ui"> - - - + + + + - + - - + + + + diff --git a/web/WEB-INF/web.xml b/web/WEB-INF/web.xml index 2852ac73..0402abaf 100644 --- a/web/WEB-INF/web.xml +++ b/web/WEB-INF/web.xml @@ -22,11 +22,6 @@ javax.faces.FACELETS_REFRESH_PERIOD -1 - - State saving method - javax.faces.STATE_SAVING_METHOD - client - Development mode for WELD, keep disabled unless really needed. Currently it messes up the website. org.jboss.weld.development