From 38ad1fd7a3f5eb21d08c866ac59a9dae109a3564 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 30 Mar 2018 19:07:48 +0200 Subject: [PATCH] Product-only: - 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 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../FinancialAdminProductWebRequestBean.java | 15 +- .../FinancialProductWebRequestBean.java | 189 -------------- .../FinancialProductWebRequestController.java | 35 --- .../FinancialsProductListWebViewBean.java | 243 ++++++++++++++++++ ...inancialsProductListWebViewController.java | 52 ++++ .../FinancialAdminCategoryWebRequestBean.java | 47 ++-- .../FinancialCategoryWebRequestBean.java | 190 -------------- ...FinancialCategoryWebRequestController.java | 25 -- .../FinancialsCategoryListWebViewBean.java | 238 +++++++++++++++++ ...nancialsCategoryListWebViewController.java | 53 ++++ .../FinancialsGenericProductConverter.java | 12 +- .../FinancialsProductCategoryConverter.java | 12 +- .../FinancialsGenericProductValidator.java | 12 +- .../FinancialsProductCategoryValidator.java | 12 +- .../product_price_input_panel_grid.tpl | 2 +- .../admin_form_product_data.tpl | 4 +- .../admin_form_category_data.tpl | 2 +- .../admin_generic_product_list.xhtml | 42 +-- .../admin_product_category_list.xhtml | 10 +- 19 files changed, 677 insertions(+), 518 deletions(-) create mode 100644 src/java/org/mxchange/jfinancials/beans/generic_product/list/FinancialsProductListWebViewBean.java create mode 100644 src/java/org/mxchange/jfinancials/beans/generic_product/list/FinancialsProductListWebViewController.java create mode 100644 src/java/org/mxchange/jfinancials/beans/product_category/list/FinancialsCategoryListWebViewBean.java create mode 100644 src/java/org/mxchange/jfinancials/beans/product_category/list/FinancialsCategoryListWebViewController.java diff --git a/src/java/org/mxchange/jfinancials/beans/generic_product/FinancialAdminProductWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/generic_product/FinancialAdminProductWebRequestBean.java index 47eb6591..bf24a547 100644 --- a/src/java/org/mxchange/jfinancials/beans/generic_product/FinancialAdminProductWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/generic_product/FinancialAdminProductWebRequestBean.java @@ -26,6 +26,7 @@ import javax.inject.Inject; import javax.inject.Named; import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; import org.mxchange.jfinancials.beans.BaseFinancialsBean; +import org.mxchange.jfinancials.beans.generic_product.list.FinancialsProductListWebViewController; import org.mxchange.jproduct.events.product.AddedProductEvent; import org.mxchange.jproduct.events.product.ProductAddedEvent; import org.mxchange.jproduct.exceptions.product.ProductAlreadyAddedException; @@ -77,12 +78,6 @@ public class FinancialAdminProductWebRequestBean extends BaseFinancialsBean impl */ private Category productCategory; - /** - * General product controller - */ - @Inject - private FinancialProductWebRequestController productController; - /** * Product's price currency code like EUR or USD */ @@ -98,6 +93,12 @@ public class FinancialAdminProductWebRequestBean extends BaseFinancialsBean impl */ private String productI18nKey; + /** + * Product list controller + */ + @Inject + private FinancialsProductListWebViewController productListController; + /** * Product's manufacturing/producing company */ @@ -148,7 +149,7 @@ public class FinancialAdminProductWebRequestBean extends BaseFinancialsBean impl */ public void addProduct () throws FaceletException { // Is product i18n key already used? - if (this.productController.isProductI18nKeyAdded(this.getProductI18nKey())) { + if (this.productListController.isProductI18nKeyAdded(this.getProductI18nKey())) { // Then throw exception throw new FaceletException("Product i18n key " + this.getProductI18nKey() + " already added."); } diff --git a/src/java/org/mxchange/jfinancials/beans/generic_product/FinancialProductWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/generic_product/FinancialProductWebRequestBean.java index f4506088..9f23decd 100644 --- a/src/java/org/mxchange/jfinancials/beans/generic_product/FinancialProductWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/generic_product/FinancialProductWebRequestBean.java @@ -16,26 +16,9 @@ */ package org.mxchange.jfinancials.beans.generic_product; -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.faces.FacesException; -import javax.inject.Inject; import javax.inject.Named; import org.mxchange.jfinancials.beans.BaseFinancialsBean; -import org.mxchange.jproduct.events.product.AddedProductEvent; -import org.mxchange.jproduct.exceptions.product.ProductNotFoundException; -import org.mxchange.jproduct.model.product.Product; -import org.mxchange.jproduct.model.product.ProductSessionBeanRemote; /** * General product controller @@ -51,184 +34,12 @@ public class FinancialProductWebRequestBean extends BaseFinancialsBean implement */ private static final long serialVersionUID = 58_137_539_530_279L; - /** - * List for all products - */ - private final List allProducts; - - /** - * List for filtered products - */ - private List filteredProducts; - - /** - * EJB for general product purposes - */ - @EJB (lookup = "java:global/jfinancials-ejb/product!org.mxchange.jproduct.model.product.ProductSessionBeanRemote") - private ProductSessionBeanRemote productBean; - - /** - * Cached products - */ - @Inject - @NamedCache (cacheName = "productCache") - private Cache productCache; - /** * Default constructor */ public FinancialProductWebRequestBean () { // Call super constructor super(); - - // Init list - this.allProducts = new LinkedList<>(); - } - - /** - * Observes events fired after a new product has been added - *

- * @param event Event to be observed - *

- * @todo Move this to own controller - */ - public void afterProductAddedEvent (@Observes final AddedProductEvent event) { - // Is all valid? - if (null == event) { - // Throw NPE - throw new NullPointerException("event is null"); //NOI18N - } else if (event.getAddedProduct() == null) { - // Throw again ... - throw new NullPointerException("event.addedProduct is null"); //NOI18N - } else if (event.getAddedProduct().getProductId() == null) { - // And again ... - throw new NullPointerException("event.addedProduct.productId is null"); //NOI18N - } else if (event.getAddedProduct().getProductId() < 1) { - // Id is invalid - throw new IllegalArgumentException(MessageFormat.format("event.addedProduct.productId={0} is not valid.", event.getAddedProduct().getProductId())); //NOI18N - } - - // Add it - this.productCache.put(event.getAddedProduct().getProductId(), event.getAddedProduct()); - this.allProducts.add(event.getAddedProduct()); - } - - @Override - @SuppressWarnings ("ReturnOfCollectionOrArrayField") - public List allProducts () throws FacesException { - // Return it - return this.allProducts; - } - - @Override - public Product findProductById (final Long productId) throws ProductNotFoundException { - // Validate parameter - if (null == productId) { - // Throw NPE - throw new NullPointerException("productId is null"); //NOI18N - } else if (productId < 1) { - // Throw IAE - throw new IllegalArgumentException(MessageFormat.format("productId={0} is invalid", productId)); //NOI18N //NOI18N - } else if (!this.productCache.containsKey(productId)) { - // Not found - throw new ProductNotFoundException(productId); - } - - // Get it from cache - final Product product = this.productCache.get(productId); - - // Return it - return product; - } - - /** - * Getter for filtered product list - *

- * @return Filtered product list - */ - @SuppressWarnings ("ReturnOfCollectionOrArrayField") - public List getFilteredProducts () { - return this.filteredProducts; - } - - /** - * Setter for filtered product list - *

- * @param filteredProducts Filtered product list - */ - @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter") - public void setFilteredProducts (final List filteredProducts) { - this.filteredProducts = filteredProducts; - } - - /** - * Initialization of this bean - */ - @PostConstruct - public void init () { - // Is cache there? - if (!this.productCache.iterator().hasNext()) { - // Get whole list - final List products = this.productBean.allProducts(); - - // "Walk" through all entries and add to cache - for (final Product product : products) { - // Add it by primary key - this.productCache.put(product.getProductId(), product); - } - } - - // Is the list empty, but filled cache? - if (this.allProducts.isEmpty() && this.productCache.iterator().hasNext()) { - // Get iterator - final Iterator> iterator = this.productCache.iterator(); - - // Build up list - while (iterator.hasNext()) { - // GEt next element - final Cache.Entry next = iterator.next(); - - // Add to list - this.allProducts.add(next.getValue()); - } - - // Sort list - this.allProducts.sort(new Comparator() { - @Override - public int compare (final Product o1, final Product o2) { - return o1.getProductId() > o2.getProductId() ? 1 : o1.getProductId() < o2.getProductId() ? -1 : 0; - } - } - ); - } - } - - @Override - public boolean isProductI18nKeyAdded (final String productI18nKey) { - // Validate parameter - if (null == productI18nKey) { - // Throw NPE - throw new NullPointerException("productI18nKey is null"); //NOI18N - } else if (productI18nKey.isEmpty()) { - // Throw IAE - throw new IllegalArgumentException("productI18nKey is empty"); //NOI18N - } - - // Default is not the same - boolean isFound = false; - - // Check all added,products - for (final Product product : this.allProducts()) { - // Is i18n key the same? - if (Objects.equals(product.getProductI18nKey(), productI18nKey)) { - // Found it - isFound = true; - break; - } - } - - // Return flag - return isFound; } } diff --git a/src/java/org/mxchange/jfinancials/beans/generic_product/FinancialProductWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/generic_product/FinancialProductWebRequestController.java index 8ef9f6dd..77b1a78a 100644 --- a/src/java/org/mxchange/jfinancials/beans/generic_product/FinancialProductWebRequestController.java +++ b/src/java/org/mxchange/jfinancials/beans/generic_product/FinancialProductWebRequestController.java @@ -17,11 +17,7 @@ package org.mxchange.jfinancials.beans.generic_product; import java.io.Serializable; -import java.util.List; import javax.ejb.Local; -import javax.faces.view.facelets.FaceletException; -import org.mxchange.jproduct.exceptions.product.ProductNotFoundException; -import org.mxchange.jproduct.model.product.Product; /** * An interface for products @@ -31,35 +27,4 @@ import org.mxchange.jproduct.model.product.Product; @Local public interface FinancialProductWebRequestController extends Serializable { - /** - * Checks whether the given product i18n key has already used. - *

- * @param productI18nKey Product i18n key - *

- * @return Whether the i18n key has been used - */ - boolean isProductI18nKeyAdded (final String productI18nKey); - - /** - * Some "getter" for a linked list of only available products - *

- * @return Only available products - *

- * @throws javax.faces.view.facelets.FaceletException If anything went wrong - */ - List allProducts () throws FaceletException; - - /** - * Returns a product instance (entity) for given primary key. If not found, - * a proper exception is thrown. - *

- * @param productId Product id (primary key) - *

- * @return Product entity matching to primary key - *

- * @throws ProductNotFoundException If a product with given primary key - * could not be found - */ - Product findProductById (final Long productId) throws ProductNotFoundException; - } diff --git a/src/java/org/mxchange/jfinancials/beans/generic_product/list/FinancialsProductListWebViewBean.java b/src/java/org/mxchange/jfinancials/beans/generic_product/list/FinancialsProductListWebViewBean.java new file mode 100644 index 00000000..e9e260cb --- /dev/null +++ b/src/java/org/mxchange/jfinancials/beans/generic_product/list/FinancialsProductListWebViewBean.java @@ -0,0 +1,243 @@ +/* + * 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.generic_product.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.FacesException; +import javax.faces.view.ViewScoped; +import javax.inject.Inject; +import javax.inject.Named; +import org.mxchange.jfinancials.beans.BaseFinancialsBean; +import org.mxchange.jproduct.events.product.AddedProductEvent; +import org.mxchange.jproduct.exceptions.product.ProductNotFoundException; +import org.mxchange.jproduct.model.product.Product; +import org.mxchange.jproduct.model.product.ProductSessionBeanRemote; + +/** + * A view-scoped bean for product lists + *

+ * @author Roland Haeder + */ +@Named ("productListController") +@ViewScoped +public class FinancialsProductListWebViewBean extends BaseFinancialsBean implements FinancialsProductListWebViewController { + + /** + * Serial number + */ + private static final long serialVersionUID = 34_869_872_672_643L; + + /** + * List for all products + */ + private final List allProducts; + + /** + * List for filtered products + */ + private List filteredProducts; + + /** + * EJB for general product purposes + */ + @EJB (lookup = "java:global/jfinancials-ejb/product!org.mxchange.jproduct.model.product.ProductSessionBeanRemote") + private ProductSessionBeanRemote productBean; + + /** + * Cached products + */ + @Inject + @NamedCache (cacheName = "productCache") + private transient Cache productCache; + + /** + * Default constructor + */ + public FinancialsProductListWebViewBean () { + // Call super constructor + super(); + + // Init list + this.allProducts = new LinkedList<>(); + } + + /** + * Observes events fired after a new product has been added + *

+ * @param event Event to be observed + *

+ * @todo Move this to own controller + */ + public void afterProductAddedEvent (@Observes final AddedProductEvent event) { + // Is all valid? + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); //NOI18N + } else if (event.getAddedProduct() == null) { + // Throw again ... + throw new NullPointerException("event.addedProduct is null"); //NOI18N + } else if (event.getAddedProduct().getProductId() == null) { + // And again ... + throw new NullPointerException("event.addedProduct.productId is null"); //NOI18N + } else if (event.getAddedProduct().getProductId() < 1) { + // Id is invalid + throw new IllegalArgumentException(MessageFormat.format("event.addedProduct.productId={0} is not valid.", event.getAddedProduct().getProductId())); //NOI18N + } + + // Add it + this.productCache.put(event.getAddedProduct().getProductId(), event.getAddedProduct()); + this.getAllProducts().add(event.getAddedProduct()); + } + + @Override + public Product findProductById (final Long productId) throws ProductNotFoundException { + // Validate parameter + if (null == productId) { + // Throw NPE + throw new NullPointerException("productId is null"); //NOI18N + } else if (productId < 1) { + // Throw IAE + throw new IllegalArgumentException(MessageFormat.format("productId={0} is invalid", productId)); //NOI18N //NOI18N + } else if (!this.productCache.containsKey(productId)) { + // Not found + throw new ProductNotFoundException(productId); + } + + // Get it from cache + final Product product = this.productCache.get(productId); + + // Return it + return product; + } + + /** + * Some "getter" for a linked list of only available products + *

+ * @return Only available products + *

+ * @throws javax.faces.view.facelets.FaceletException If anything went wrong + */ + @SuppressWarnings ("ReturnOfCollectionOrArrayField") + public List getAllProducts () throws FacesException { + // Return it + return this.allProducts; + } + + /** + * Getter for filtered product list + *

+ * @return Filtered product list + */ + @SuppressWarnings ("ReturnOfCollectionOrArrayField") + public List getFilteredProducts () { + return this.filteredProducts; + } + + /** + * Setter for filtered product list + *

+ * @param filteredProducts Filtered product list + */ + @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter") + public void setFilteredProducts (final List filteredProducts) { + this.filteredProducts = filteredProducts; + } + + /** + * Initialization of this bean + */ + @PostConstruct + public void init () { + // Is cache there? + if (!this.productCache.iterator().hasNext()) { + // Get whole list + final List products = this.productBean.allProducts(); + + // "Walk" through all entries and add to cache + for (final Product product : products) { + // Add it by primary key + this.productCache.put(product.getProductId(), product); + } + } + + // Is the list empty, but filled cache? + if (this.getAllProducts().isEmpty() && this.productCache.iterator().hasNext()) { + // Get iterator + final Iterator> iterator = this.productCache.iterator(); + + // Build up list + while (iterator.hasNext()) { + // GEt next element + final Cache.Entry next = iterator.next(); + + // Add to list + this.getAllProducts().add(next.getValue()); + } + + // Sort list + this.getAllProducts().sort(new Comparator() { + @Override + public int compare (final Product o1, final Product o2) { + return o1.getProductId() > o2.getProductId() ? 1 : o1.getProductId() < o2.getProductId() ? -1 : 0; + } + } + ); + + // Set whole list + this.setFilteredProducts(this.getAllProducts()); + } + } + + @Override + public boolean isProductI18nKeyAdded (final String productI18nKey) { + // Validate parameter + if (null == productI18nKey) { + // Throw NPE + throw new NullPointerException("productI18nKey is null"); //NOI18N + } else if (productI18nKey.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("productI18nKey is empty"); //NOI18N + } + + // Default is not the same + boolean isFound = false; + + // Check all added,products + for (final Product product : this.getAllProducts()) { + // Is i18n key the same? + if (Objects.equals(product.getProductI18nKey(), productI18nKey)) { + // Found it + isFound = true; + break; + } + } + + // Return flag + return isFound; + } + +} diff --git a/src/java/org/mxchange/jfinancials/beans/generic_product/list/FinancialsProductListWebViewController.java b/src/java/org/mxchange/jfinancials/beans/generic_product/list/FinancialsProductListWebViewController.java new file mode 100644 index 00000000..dca6068f --- /dev/null +++ b/src/java/org/mxchange/jfinancials/beans/generic_product/list/FinancialsProductListWebViewController.java @@ -0,0 +1,52 @@ +/* + * 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.generic_product.list; + +import java.io.Serializable; +import org.mxchange.jproduct.exceptions.product.ProductNotFoundException; +import org.mxchange.jproduct.model.product.Product; + +/** + * An interface of product list backing beans + *

+ * @author Roland Häder + */ +public interface FinancialsProductListWebViewController extends Serializable { + + /** + * Returns a product instance (entity) for given primary key. If not found, + * a proper exception is thrown. + *

+ * @param productId Product id (primary key) + *

+ * @return Product entity matching to primary key + *

+ * @throws ProductNotFoundException If a product with given primary key + * could not be found + */ + Product findProductById (final Long productId) throws ProductNotFoundException; + + /** + * Checks whether the given product i18n key has already used. + *

+ * @param productI18nKey Product i18n key + *

+ * @return Whether the i18n key has been used + */ + boolean isProductI18nKeyAdded (final String productI18nKey); + +} diff --git a/src/java/org/mxchange/jfinancials/beans/product_category/FinancialAdminCategoryWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/product_category/FinancialAdminCategoryWebRequestBean.java index 65f0940c..4637505a 100644 --- a/src/java/org/mxchange/jfinancials/beans/product_category/FinancialAdminCategoryWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/product_category/FinancialAdminCategoryWebRequestBean.java @@ -24,6 +24,7 @@ import javax.faces.view.facelets.FaceletException; import javax.inject.Inject; import javax.inject.Named; import org.mxchange.jfinancials.beans.BaseFinancialsBean; +import org.mxchange.jfinancials.beans.product_category.list.FinancialsCategoryListWebViewController; import org.mxchange.jproduct.events.category.AddedCategoryEvent; import org.mxchange.jproduct.events.category.CategoryAddedEvent; import org.mxchange.jproduct.exceptions.category.CategoryAlreadyAddedException; @@ -58,22 +59,22 @@ public class FinancialAdminCategoryWebRequestBean extends BaseFinancialsBean imp @EJB (lookup = "java:global/jfinancials-ejb/adminCategory!org.mxchange.jproduct.model.category.AdminCategorySessionBeanRemote") private AdminCategorySessionBeanRemote categoryBean; + /** + * Category categoryI18nKey + */ + private String categoryI18nKey; + /** * General category controller */ @Inject - private FinancialCategoryWebRequestController categoryController; + private FinancialsCategoryListWebViewController categoryListController; /** * Whether this category is shown in statistics */ private Boolean categoryShownInStatistics; - /** - * Category categoryI18nKey - */ - private String categoryI18nKey; - /** * Parent category */ @@ -94,7 +95,7 @@ public class FinancialAdminCategoryWebRequestBean extends BaseFinancialsBean imp */ public void addCategory () throws FaceletException { // Is i18n key already used? - if (this.categoryController.isCategoryI18nKeyAdded(this.getCategoryI18nKey())) { + if (this.categoryListController.isCategoryI18nKeyAdded(this.getCategoryI18nKey())) { // Throw exception throw new FaceletException("Category i18n key " + this.getCategoryI18nKey() + " is already used."); } @@ -121,39 +122,39 @@ public class FinancialAdminCategoryWebRequestBean extends BaseFinancialsBean imp } /** - * Getter for whether category is shown in statistics + * Getter for category i18n key *

- * @return Whether category is shown in statistics + * @return Category i18n key */ - public Boolean getCategoryShownInStatistics () { - return this.categoryShownInStatistics; + public String getCategoryI18nKey () { + return this.categoryI18nKey; } /** - * Setter for whether category is shown in statistics + * Setter for category i18n key *

- * @param categoryShownInStatistics Whether category is shown in statistics + * @param categoryI18nKey Category i18n key */ - public void setCategoryShownInStatistics (final Boolean categoryShownInStatistics) { - this.categoryShownInStatistics = categoryShownInStatistics; + public void setCategoryI18nKey (final String categoryI18nKey) { + this.categoryI18nKey = categoryI18nKey; } /** - * Getter for category i18n key + * Getter for whether category is shown in statistics *

- * @return Category i18n key + * @return Whether category is shown in statistics */ - public String getCategoryI18nKey () { - return this.categoryI18nKey; + public Boolean getCategoryShownInStatistics () { + return this.categoryShownInStatistics; } /** - * Setter for category i18n key + * Setter for whether category is shown in statistics *

- * @param categoryI18nKey Category i18n key + * @param categoryShownInStatistics Whether category is shown in statistics */ - public void setCategoryI18nKey (final String categoryI18nKey) { - this.categoryI18nKey = categoryI18nKey; + public void setCategoryShownInStatistics (final Boolean categoryShownInStatistics) { + this.categoryShownInStatistics = categoryShownInStatistics; } /** diff --git a/src/java/org/mxchange/jfinancials/beans/product_category/FinancialCategoryWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/product_category/FinancialCategoryWebRequestBean.java index 20d51e3b..fa7c93c1 100644 --- a/src/java/org/mxchange/jfinancials/beans/product_category/FinancialCategoryWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/product_category/FinancialCategoryWebRequestBean.java @@ -16,25 +16,9 @@ */ package org.mxchange.jfinancials.beans.product_category; -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.jfinancials.beans.BaseFinancialsBean; -import org.mxchange.jproduct.events.category.AddedCategoryEvent; -import org.mxchange.jproduct.exceptions.category.CategoryNotFoundException; -import org.mxchange.jproduct.model.category.Category; -import org.mxchange.jproduct.model.category.CategorySessionBeanRemote; /** * General (product) category controller @@ -50,186 +34,12 @@ public class FinancialCategoryWebRequestBean extends BaseFinancialsBean implemen */ private static final long serialVersionUID = 58_137_539_530_279L; - /** - * List of all categories - */ - private final List allCategories; - - /** - * EJB for general category stuff - */ - @EJB (lookup = "java:global/jfinancials-ejb/category!org.mxchange.jproduct.model.category.CategorySessionBeanRemote") - private CategorySessionBeanRemote categoryBean; - - /** - * Cache for all product categories - */ - @Inject - @NamedCache (cacheName = "categoryCache") - private Cache categoryCache; - - /** - * A list of filtered categories - */ - private List filteredCategories; - /** * Default constructor */ public FinancialCategoryWebRequestBean () { // Call super constructor super(); - - // Init list - this.allCategories = new LinkedList<>(); - } - - /** - * Observes events fired after a new product category has been added - *

- * @param event Event to be observed - */ - public void afterCategoryAddedEvent (@Observes final AddedCategoryEvent event) { - // Is all valid? - if (null == event) { - // Throw NPE - throw new NullPointerException("event is null"); //NOI18N - } else if (event.getAddedCategory() == null) { - // Throw again ... - throw new NullPointerException("event.addedCategory is null"); //NOI18N - } else if (event.getAddedCategory().getCategoryId() == null) { - // And again ... - throw new NullPointerException("event.addedCategory.categoryId is null"); //NOI18N - } else if (event.getAddedCategory().getCategoryId() < 1) { - // Id is invalid - throw new IllegalArgumentException(MessageFormat.format("event.addedCategory.categoryId={0} is not valid.", event.getAddedCategory().getCategoryId())); //NOI18N - } - - // Add the category - this.categoryCache.put(event.getAddedCategory().getCategoryId(), event.getAddedCategory()); - this.allCategories.add(event.getAddedCategory()); - } - - /** - * Getter for a list of all categories - *

- * @return All categories - */ - @SuppressWarnings ("ReturnOfCollectionOrArrayField") - public List allCategories () { - // Return it - return this.allCategories; - } - - @Override - public Category findCategoryById (final Long categoryId) throws CategoryNotFoundException { - // Validate parameter - if (null == categoryId) { - // Throw NPE - throw new NullPointerException("categoryId is null"); //NOI18N - } else if (categoryId < 1) { - // Throw IAE - throw new IllegalArgumentException("categoryId=" + categoryId + " is invalid"); //NOI18N - } else if (!this.categoryCache.containsKey(categoryId)) { - // Not found - throw new CategoryNotFoundException(categoryId); - } - - // Get it from cache - final Category category = this.categoryCache.get(categoryId); - - // Return it - return category; - } - - /** - * Getter for filtered category list - *

- * @return Filtered category list - */ - @SuppressWarnings ("ReturnOfCollectionOrArrayField") - public List getFilteredCategories () { - return this.filteredCategories; - } - - /** - * Setter for filtered category list - *

- * @param filteredCategories Filtered category list - */ - @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter") - public void setFilteredCategories (final List filteredCategories) { - this.filteredCategories = filteredCategories; - } - - /** - * Initialization of this bean - */ - @PostConstruct - public void init () { - // Is cache there? - if (!this.categoryCache.iterator().hasNext()) { - // Get whole list - final List categories = this.categoryBean.allCategories(); - - // "Walk" through all entries and add to cache - for (final Category category : categories) { - // Add it by primary key - this.categoryCache.put(category.getCategoryId(), category); - } - } - - // Is the list empty, but filled cache? - if (this.allCategories.isEmpty() && this.categoryCache.iterator().hasNext()) { - // Get iterator - final Iterator> iterator = this.categoryCache.iterator(); - - // Build up list - while (iterator.hasNext()) { - // GEt next element - final Cache.Entry next = iterator.next(); - - // Add to list - this.allCategories.add(next.getValue()); - } - - // Sort list - this.allCategories.sort(new Comparator() { - @Override - public int compare (final Category o1, final Category o2) { - return o1.getCategoryId() > o2.getCategoryId() ? 1 : o1.getCategoryId() < o2.getCategoryId() ? -1 : 0; - } - } - ); - } - } - - @Override - public boolean isCategoryI18nKeyAdded (final String categoryI18nKey) { - // Validate parameter - if (null == categoryI18nKey) { - // Throw NPE - throw new NullPointerException("categoryI18nKey is null"); //NOI18N - } else if (categoryI18nKey.isEmpty()) { - // Throw IAE - throw new IllegalArgumentException("categoryI18nKey is empty"); //NOI18N - } - - // Default is not the same - boolean isFound = false; - - // Check all added,products - for (final Category category : this.allCategories()) { - // Is i18n key the same? - if (Objects.equals(category.getCategoryI18nKey(), categoryI18nKey)) { - // Found it - isFound = true; - break; - } - } - - // Return flag - return isFound; } } diff --git a/src/java/org/mxchange/jfinancials/beans/product_category/FinancialCategoryWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/product_category/FinancialCategoryWebRequestController.java index 780f02e6..4522115d 100644 --- a/src/java/org/mxchange/jfinancials/beans/product_category/FinancialCategoryWebRequestController.java +++ b/src/java/org/mxchange/jfinancials/beans/product_category/FinancialCategoryWebRequestController.java @@ -17,8 +17,6 @@ package org.mxchange.jfinancials.beans.product_category; import java.io.Serializable; -import org.mxchange.jproduct.exceptions.category.CategoryNotFoundException; -import org.mxchange.jproduct.model.category.Category; /** * An interface for (product) categories @@ -27,27 +25,4 @@ import org.mxchange.jproduct.model.category.Category; */ public interface FinancialCategoryWebRequestController extends Serializable { - /** - * Returns a category instance (entity) for given primary key. If not found, - * a proper exception is thrown. - *

- * @param categoryId Category id (primary key) - *

- * @return Category entity matching to primary key - *

- * @throws CategoryNotFoundException If a category with given primary key - * could not be found - */ - Category findCategoryById (final Long categoryId) throws CategoryNotFoundException; - - /** - * Checks whether given category i18n key has already been used. - *

- * @param categoryI18nKey Category i18n key - *

- * @return Whether i18n key is already added - *

- */ - boolean isCategoryI18nKeyAdded (final String categoryI18nKey); - } diff --git a/src/java/org/mxchange/jfinancials/beans/product_category/list/FinancialsCategoryListWebViewBean.java b/src/java/org/mxchange/jfinancials/beans/product_category/list/FinancialsCategoryListWebViewBean.java new file mode 100644 index 00000000..3f7aac14 --- /dev/null +++ b/src/java/org/mxchange/jfinancials/beans/product_category/list/FinancialsCategoryListWebViewBean.java @@ -0,0 +1,238 @@ +/* + * 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.product_category.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.jfinancials.beans.BaseFinancialsBean; +import org.mxchange.jproduct.events.category.AddedCategoryEvent; +import org.mxchange.jproduct.exceptions.category.CategoryNotFoundException; +import org.mxchange.jproduct.model.category.Category; +import org.mxchange.jproduct.model.category.CategorySessionBeanRemote; + +/** + * A view-scoped bean for product lists + *

+ * @author Roland Haeder + */ +@Named ("categoryListController") +@ViewScoped +public class FinancialsCategoryListWebViewBean extends BaseFinancialsBean implements FinancialsCategoryListWebViewController { + + /** + * Serial number + */ + private static final long serialVersionUID = 34_869_872_672_644L; + + /** + * List of all categories + */ + private final List allCategories; + + /** + * EJB for general category stuff + */ + @EJB (lookup = "java:global/jfinancials-ejb/category!org.mxchange.jproduct.model.category.CategorySessionBeanRemote") + private CategorySessionBeanRemote categoryBean; + + /** + * Cache for all product categories + */ + @Inject + @NamedCache (cacheName = "categoryCache") + private transient Cache categoryCache; + + /** + * A list of filtered categories + */ + private List filteredCategories; + + /** + * Default constructor + */ + public FinancialsCategoryListWebViewBean () { + // Call super constructor + super(); + + // Init list + this.allCategories = new LinkedList<>(); + } + + /** + * Observes events fired after a new product category has been added + *

+ * @param event Event to be observed + */ + public void afterCategoryAddedEvent (@Observes final AddedCategoryEvent event) { + // Is all valid? + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); //NOI18N + } else if (event.getAddedCategory() == null) { + // Throw again ... + throw new NullPointerException("event.addedCategory is null"); //NOI18N + } else if (event.getAddedCategory().getCategoryId() == null) { + // And again ... + throw new NullPointerException("event.addedCategory.categoryId is null"); //NOI18N + } else if (event.getAddedCategory().getCategoryId() < 1) { + // Id is invalid + throw new IllegalArgumentException(MessageFormat.format("event.addedCategory.categoryId={0} is not valid.", event.getAddedCategory().getCategoryId())); //NOI18N + } + + // Add the category + this.categoryCache.put(event.getAddedCategory().getCategoryId(), event.getAddedCategory()); + this.getAllCategories().add(event.getAddedCategory()); + } + + @Override + public Category findCategoryById (final Long categoryId) throws CategoryNotFoundException { + // Validate parameter + if (null == categoryId) { + // Throw NPE + throw new NullPointerException("categoryId is null"); //NOI18N + } else if (categoryId < 1) { + // Throw IAE + throw new IllegalArgumentException("categoryId=" + categoryId + " is invalid"); //NOI18N + } else if (!this.categoryCache.containsKey(categoryId)) { + // Not found + throw new CategoryNotFoundException(categoryId); + } + + // Get it from cache + final Category category = this.categoryCache.get(categoryId); + + // Return it + return category; + } + + /** + * Getter for a list of all categories + *

+ * @return All categories + */ + @SuppressWarnings ("ReturnOfCollectionOrArrayField") + public List getAllCategories () { + // Return it + return this.allCategories; + } + + /** + * Getter for filtered category list + *

+ * @return Filtered category list + */ + @SuppressWarnings ("ReturnOfCollectionOrArrayField") + public List getFilteredCategories () { + return this.filteredCategories; + } + + /** + * Setter for filtered category list + *

+ * @param filteredCategories Filtered category list + */ + @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter") + public void setFilteredCategories (final List filteredCategories) { + this.filteredCategories = filteredCategories; + } + + /** + * Initialization of this bean + */ + @PostConstruct + public void init () { + // Is cache there? + if (!this.categoryCache.iterator().hasNext()) { + // Get whole list + final List categories = this.categoryBean.allCategories(); + + // "Walk" through all entries and add to cache + for (final Category category : categories) { + // Add it by primary key + this.categoryCache.put(category.getCategoryId(), category); + } + } + + // Is the list empty, but filled cache? + if (this.allCategories.isEmpty() && this.categoryCache.iterator().hasNext()) { + // Get iterator + final Iterator> iterator = this.categoryCache.iterator(); + + // Build up list + while (iterator.hasNext()) { + // GEt next element + final Cache.Entry next = iterator.next(); + + // Add to list + this.allCategories.add(next.getValue()); + } + + // Sort list + this.allCategories.sort(new Comparator() { + @Override + public int compare (final Category o1, final Category o2) { + return o1.getCategoryId() > o2.getCategoryId() ? 1 : o1.getCategoryId() < o2.getCategoryId() ? -1 : 0; + } + } + ); + + // Set whole list + this.setFilteredCategories(this.getAllCategories()); + } + } + + @Override + public boolean isCategoryI18nKeyAdded (final String categoryI18nKey) { + // Validate parameter + if (null == categoryI18nKey) { + // Throw NPE + throw new NullPointerException("categoryI18nKey is null"); //NOI18N + } else if (categoryI18nKey.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("categoryI18nKey is empty"); //NOI18N + } + + // Default is not the same + boolean isFound = false; + + // Check all added,products + for (final Category category : this.getAllCategories()) { + // Is i18n key the same? + if (Objects.equals(category.getCategoryI18nKey(), categoryI18nKey)) { + // Found it + isFound = true; + break; + } + } + + // Return flag + return isFound; + } + +} diff --git a/src/java/org/mxchange/jfinancials/beans/product_category/list/FinancialsCategoryListWebViewController.java b/src/java/org/mxchange/jfinancials/beans/product_category/list/FinancialsCategoryListWebViewController.java new file mode 100644 index 00000000..69ea389a --- /dev/null +++ b/src/java/org/mxchange/jfinancials/beans/product_category/list/FinancialsCategoryListWebViewController.java @@ -0,0 +1,53 @@ +/* + * 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.product_category.list; + +import java.io.Serializable; +import org.mxchange.jproduct.exceptions.category.CategoryNotFoundException; +import org.mxchange.jproduct.model.category.Category; + +/** + * An interface of category list backing beans + *

+ * @author Roland Häder + */ +public interface FinancialsCategoryListWebViewController extends Serializable { + + /** + * Returns a category instance (entity) for given primary key. If not found, + * a proper exception is thrown. + *

+ * @param categoryId Category id (primary key) + *

+ * @return Category entity matching to primary key + *

+ * @throws CategoryNotFoundException If a category with given primary key + * could not be found + */ + Category findCategoryById (final Long categoryId) throws CategoryNotFoundException; + + /** + * Checks whether given category i18n key has already been used. + *

+ * @param categoryI18nKey Category i18n key + *

+ * @return Whether i18n key is already added + *

+ */ + boolean isCategoryI18nKeyAdded (final String categoryI18nKey); + +} diff --git a/src/java/org/mxchange/jfinancials/converter/generic_product/FinancialsGenericProductConverter.java b/src/java/org/mxchange/jfinancials/converter/generic_product/FinancialsGenericProductConverter.java index ee8024f6..f0130664 100644 --- a/src/java/org/mxchange/jfinancials/converter/generic_product/FinancialsGenericProductConverter.java +++ b/src/java/org/mxchange/jfinancials/converter/generic_product/FinancialsGenericProductConverter.java @@ -22,8 +22,8 @@ import javax.faces.context.FacesContext; import javax.faces.convert.Converter; import javax.faces.convert.ConverterException; import javax.faces.convert.FacesConverter; -import org.mxchange.jfinancials.beans.generic_product.FinancialProductWebRequestBean; -import org.mxchange.jfinancials.beans.generic_product.FinancialProductWebRequestController; +import org.mxchange.jfinancials.beans.generic_product.list.FinancialsProductListWebViewBean; +import org.mxchange.jfinancials.beans.generic_product.list.FinancialsProductListWebViewController; import org.mxchange.jproduct.exceptions.product.ProductNotFoundException; import org.mxchange.jproduct.model.product.Product; @@ -38,14 +38,14 @@ public class FinancialsGenericProductConverter implements Converter { /** * Product backing bean */ - private static FinancialProductWebRequestController PRODUCT_CONTROLLER; + private static FinancialsProductListWebViewController PRODUCT_LIST_CONTROLLER; @Override public Product getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { // Is the instance there? - if (null == PRODUCT_CONTROLLER) { + if (null == PRODUCT_LIST_CONTROLLER) { // Get bean from CDI directly - PRODUCT_CONTROLLER = CDI.current().select(FinancialProductWebRequestBean.class).get(); + PRODUCT_LIST_CONTROLLER = CDI.current().select(FinancialsProductListWebViewBean.class).get(); } // Is the value null or empty? @@ -65,7 +65,7 @@ public class FinancialsGenericProductConverter implements Converter { final Long productId = Long.valueOf(submittedValue); // Try to get user instance from it - product = PRODUCT_CONTROLLER.findProductById(productId); + product = PRODUCT_LIST_CONTROLLER.findProductById(productId); } catch (final NumberFormatException ex) { // Throw again throw new ConverterException(ex); diff --git a/src/java/org/mxchange/jfinancials/converter/product_category/FinancialsProductCategoryConverter.java b/src/java/org/mxchange/jfinancials/converter/product_category/FinancialsProductCategoryConverter.java index bf167ab7..c443dbad 100644 --- a/src/java/org/mxchange/jfinancials/converter/product_category/FinancialsProductCategoryConverter.java +++ b/src/java/org/mxchange/jfinancials/converter/product_category/FinancialsProductCategoryConverter.java @@ -22,8 +22,8 @@ import javax.faces.context.FacesContext; import javax.faces.convert.Converter; import javax.faces.convert.ConverterException; import javax.faces.convert.FacesConverter; -import org.mxchange.jfinancials.beans.product_category.FinancialCategoryWebRequestBean; -import org.mxchange.jfinancials.beans.product_category.FinancialCategoryWebRequestController; +import org.mxchange.jfinancials.beans.product_category.list.FinancialsCategoryListWebViewBean; +import org.mxchange.jfinancials.beans.product_category.list.FinancialsCategoryListWebViewController; import org.mxchange.jproduct.exceptions.category.CategoryNotFoundException; import org.mxchange.jproduct.model.category.Category; @@ -38,14 +38,14 @@ public class FinancialsProductCategoryConverter implements Converter { /** * Category backing bean */ - private static FinancialCategoryWebRequestController CATEGORY_CONTROLLER; + private static FinancialsCategoryListWebViewController CATEGORY_LIST_CONTROLLER; @Override public Category getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { // Is the instance there? - if (null == CATEGORY_CONTROLLER) { + if (null == CATEGORY_LIST_CONTROLLER) { // Get bean from CDI directly - CATEGORY_CONTROLLER = CDI.current().select(FinancialCategoryWebRequestBean.class).get(); + CATEGORY_LIST_CONTROLLER = CDI.current().select(FinancialsCategoryListWebViewBean.class).get(); } // Is the value null or empty? @@ -65,7 +65,7 @@ public class FinancialsProductCategoryConverter implements Converter { final Long categoryId = Long.valueOf(submittedValue); // Try to get user instance from it - category = CATEGORY_CONTROLLER.findCategoryById(categoryId); + category = CATEGORY_LIST_CONTROLLER.findCategoryById(categoryId); } catch (final NumberFormatException ex) { // Throw again throw new ConverterException(ex); diff --git a/src/java/org/mxchange/jfinancials/validator/generic_product/FinancialsGenericProductValidator.java b/src/java/org/mxchange/jfinancials/validator/generic_product/FinancialsGenericProductValidator.java index 8d30c5ed..6d165c2f 100644 --- a/src/java/org/mxchange/jfinancials/validator/generic_product/FinancialsGenericProductValidator.java +++ b/src/java/org/mxchange/jfinancials/validator/generic_product/FinancialsGenericProductValidator.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.generic_product.FinancialProductWebRequestBean; -import org.mxchange.jfinancials.beans.generic_product.FinancialProductWebRequestController; +import org.mxchange.jfinancials.beans.generic_product.list.FinancialsProductListWebViewBean; +import org.mxchange.jfinancials.beans.generic_product.list.FinancialsProductListWebViewController; /** * A validator for generic products, will fail when product i18n key is already @@ -39,7 +39,7 @@ public class FinancialsGenericProductValidator extends BaseStringValidator { /** * Backing bean for product categories */ - private static FinancialProductWebRequestController PRODUCT_CONTROLLER; + private static FinancialsProductListWebViewController PRODUCT_LIST_CONTROLLER; /** * Serial number @@ -55,13 +55,13 @@ public class FinancialsGenericProductValidator extends BaseStringValidator { super.preValidate(context, component, productI18nKey, requiredFields, Boolean.FALSE); // Is the instance there? - if (null == PRODUCT_CONTROLLER) { + if (null == PRODUCT_LIST_CONTROLLER) { // Then get it from CDI - PRODUCT_CONTROLLER = CDI.current().select(FinancialProductWebRequestBean.class).get(); + PRODUCT_LIST_CONTROLLER = CDI.current().select(FinancialsProductListWebViewBean.class).get(); } // Check, if the name has already been used - if (PRODUCT_CONTROLLER.isProductI18nKeyAdded((String) productI18nKey)) { + if (PRODUCT_LIST_CONTROLLER.isProductI18nKeyAdded((String) productI18nKey)) { // Create message final String message = MessageFormat.format("I18n key {0} is already used. Please type an other.", productI18nKey); diff --git a/src/java/org/mxchange/jfinancials/validator/product_category/FinancialsProductCategoryValidator.java b/src/java/org/mxchange/jfinancials/validator/product_category/FinancialsProductCategoryValidator.java index 79477eca..3c86937e 100644 --- a/src/java/org/mxchange/jfinancials/validator/product_category/FinancialsProductCategoryValidator.java +++ b/src/java/org/mxchange/jfinancials/validator/product_category/FinancialsProductCategoryValidator.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.product_category.FinancialCategoryWebRequestBean; -import org.mxchange.jfinancials.beans.product_category.FinancialCategoryWebRequestController; +import org.mxchange.jfinancials.beans.product_category.list.FinancialsCategoryListWebViewBean; +import org.mxchange.jfinancials.beans.product_category.list.FinancialsCategoryListWebViewController; /** * A validator for product categories, will fail when category i18n key is @@ -39,7 +39,7 @@ public class FinancialsProductCategoryValidator extends BaseStringValidator { /** * Backing bean for product categories */ - private static FinancialCategoryWebRequestController CATEGORY_CONTROLLER; + private static FinancialsCategoryListWebViewController CATEGORY_LIST_CONTROLLER; /** * Serial number @@ -55,13 +55,13 @@ public class FinancialsProductCategoryValidator extends BaseStringValidator { super.preValidate(context, component, categoryI18nKey, requiredFields, Boolean.FALSE); // Is the instance there? - if (null == CATEGORY_CONTROLLER) { + if (null == CATEGORY_LIST_CONTROLLER) { // Then get it from CDI - CATEGORY_CONTROLLER = CDI.current().select(FinancialCategoryWebRequestBean.class).get(); + CATEGORY_LIST_CONTROLLER = CDI.current().select(FinancialsCategoryListWebViewBean.class).get(); } // Check, if the name has already been used - if (CATEGORY_CONTROLLER.isCategoryI18nKeyAdded((String) categoryI18nKey)) { + if (CATEGORY_LIST_CONTROLLER.isCategoryI18nKeyAdded((String) categoryI18nKey)) { // Create message final String message = MessageFormat.format("I18n key {0} is already used. Please type an other.", categoryI18nKey); diff --git a/web/WEB-INF/resources/tags/input/panel_grid/generic_product/product_price_input_panel_grid.tpl b/web/WEB-INF/resources/tags/input/panel_grid/generic_product/product_price_input_panel_grid.tpl index 4dfc5447..c94e106f 100644 --- a/web/WEB-INF/resources/tags/input/panel_grid/generic_product/product_price_input_panel_grid.tpl +++ b/web/WEB-INF/resources/tags/input/panel_grid/generic_product/product_price_input_panel_grid.tpl @@ -6,7 +6,7 @@ xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:p="http://primefaces.org/ui"> - + diff --git a/web/WEB-INF/templates/admin/generic_product/admin_form_product_data.tpl b/web/WEB-INF/templates/admin/generic_product/admin_form_product_data.tpl index d24cea0e..92020f1f 100644 --- a/web/WEB-INF/templates/admin/generic_product/admin_form_product_data.tpl +++ b/web/WEB-INF/templates/admin/generic_product/admin_form_product_data.tpl @@ -23,7 +23,7 @@ > - + @@ -80,7 +80,7 @@ > - + diff --git a/web/WEB-INF/templates/admin/product_category/admin_form_category_data.tpl b/web/WEB-INF/templates/admin/product_category/admin_form_category_data.tpl index 5360ca07..65dbfd42 100644 --- a/web/WEB-INF/templates/admin/product_category/admin_form_category_data.tpl +++ b/web/WEB-INF/templates/admin/product_category/admin_form_category_data.tpl @@ -20,7 +20,7 @@ > - + diff --git a/web/admin/generic_product/admin_generic_product_list.xhtml b/web/admin/generic_product/admin_generic_product_list.xhtml index 5cd8d7e0..973c5d18 100644 --- a/web/admin/generic_product/admin_generic_product_list.xhtml +++ b/web/admin/generic_product/admin_generic_product_list.xhtml @@ -17,16 +17,21 @@ +

+ +

+ - - + + + + + + + - + + - - + + @@ -53,7 +64,7 @@ - + @@ -68,8 +79,7 @@ title="#{project.FILTER_BY_MULTIPLE_PRODUCT_CATEGORIES_TITLE}" > - - + @@ -78,18 +88,18 @@ - + - + - + @@ -108,7 +118,7 @@ title="#{msg.FILTER_BY_MULTIPLE_COMPANIES_TITLE}" > - + @@ -164,7 +174,7 @@ type="submit" value="#{project.BUTTON_ADMIN_ADD_GENERIC_PRODUCT}" action="#{adminProductController.addProduct()}" - update=":master:form-list-products:table-list-products" + update=":master:form-list-products:productList" /> diff --git a/web/admin/product_category/admin_product_category_list.xhtml b/web/admin/product_category/admin_product_category_list.xhtml index 74bc2ac6..44f7668f 100644 --- a/web/admin/product_category/admin_product_category_list.xhtml +++ b/web/admin/product_category/admin_product_category_list.xhtml @@ -18,9 +18,9 @@ - + @@ -68,7 +68,7 @@ > - + @@ -118,7 +118,7 @@ type="submit" value="#{project.BUTTON_ADMIN_ADD_PRODUCT_CATEGORY}" action="#{adminCategoryController.addCategory()}" - update=":master:form-list-categories:table-list-categories" + update=":master:form-list-categories:categoryList" /> -- 2.39.5