]> git.mxchange.org Git - jfinancials-war.git/commitdiff
Product-only:
authorRoland Häder <roland@mxchange.org>
Fri, 30 Mar 2018 17:07:48 +0000 (19:07 +0200)
committerRoland Häder <roland@mxchange.org>
Fri, 30 Mar 2018 17:07:48 +0000 (19:07 +0200)
- 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

Signed-off-by: Roland Häder <roland@mxchange.org>
19 files changed:
src/java/org/mxchange/jfinancials/beans/generic_product/FinancialAdminProductWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/generic_product/FinancialProductWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/generic_product/FinancialProductWebRequestController.java
src/java/org/mxchange/jfinancials/beans/generic_product/list/FinancialsProductListWebViewBean.java [new file with mode: 0644]
src/java/org/mxchange/jfinancials/beans/generic_product/list/FinancialsProductListWebViewController.java [new file with mode: 0644]
src/java/org/mxchange/jfinancials/beans/product_category/FinancialAdminCategoryWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/product_category/FinancialCategoryWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/product_category/FinancialCategoryWebRequestController.java
src/java/org/mxchange/jfinancials/beans/product_category/list/FinancialsCategoryListWebViewBean.java [new file with mode: 0644]
src/java/org/mxchange/jfinancials/beans/product_category/list/FinancialsCategoryListWebViewController.java [new file with mode: 0644]
src/java/org/mxchange/jfinancials/converter/generic_product/FinancialsGenericProductConverter.java
src/java/org/mxchange/jfinancials/converter/product_category/FinancialsProductCategoryConverter.java
src/java/org/mxchange/jfinancials/validator/generic_product/FinancialsGenericProductValidator.java
src/java/org/mxchange/jfinancials/validator/product_category/FinancialsProductCategoryValidator.java
web/WEB-INF/resources/tags/input/panel_grid/generic_product/product_price_input_panel_grid.tpl
web/WEB-INF/templates/admin/generic_product/admin_form_product_data.tpl
web/WEB-INF/templates/admin/product_category/admin_form_category_data.tpl
web/admin/generic_product/admin_generic_product_list.xhtml
web/admin/product_category/admin_product_category_list.xhtml

index 47eb659180862d1072405281aadd88dfc1c857b3..bf24a54723bf9488f9b4863b3ef9146ec675b52b 100644 (file)
@@ -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.");
                }
index f45060881daacdbb166660aa9991975ab1820533..9f23decde79f0e437290fe29486e71d5c42fbe98 100644 (file)
  */
 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<Product> allProducts;
-
-       /**
-        * List for filtered products
-        */
-       private List<Product> 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<Long, Product> 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
-        * <p>
-        * @param event Event to be observed
-        * <p>
-        * @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<Product> 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
-        * <p>
-        * @return Filtered product list
-        */
-       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
-       public List<Product> getFilteredProducts () {
-               return this.filteredProducts;
-       }
-
-       /**
-        * Setter for filtered product list
-        * <p>
-        * @param filteredProducts Filtered product list
-        */
-       @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
-       public void setFilteredProducts (final List<Product> 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<Product> 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<Cache.Entry<Long, Product>> iterator = this.productCache.iterator();
-
-                       // Build up list
-                       while (iterator.hasNext()) {
-                               // GEt next element
-                               final Cache.Entry<Long, Product> next = iterator.next();
-
-                               // Add to list
-                               this.allProducts.add(next.getValue());
-                       }
-
-                       // Sort list
-                       this.allProducts.sort(new Comparator<Product>() {
-                               @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;
        }
 
 }
index 8ef9f6dd8a2702a037402f8c14d24b9f1779a080..77b1a78acbc14f5f6754ad627d8e262784cb1d63 100644 (file)
 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.
-        * <p>
-        * @param productI18nKey Product i18n key
-        * <p>
-        * @return Whether the i18n key has been used
-        */
-       boolean isProductI18nKeyAdded (final String productI18nKey);
-
-       /**
-        * Some "getter" for a linked list of only available products
-        * <p>
-        * @return Only available products
-        * <p>
-        * @throws javax.faces.view.facelets.FaceletException If anything went wrong
-        */
-       List<Product> allProducts () throws FaceletException;
-
-       /**
-        * Returns a product instance (entity) for given primary key. If not found,
-        * a proper exception is thrown.
-        * <p>
-        * @param productId Product id (primary key)
-        * <p>
-        * @return Product entity matching to primary key
-        * <p>
-        * @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 (file)
index 0000000..e9e260c
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+ */
+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
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@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<Product> allProducts;
+
+       /**
+        * List for filtered products
+        */
+       private List<Product> 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<Long, Product> 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
+        * <p>
+        * @param event Event to be observed
+        * <p>
+        * @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
+        * <p>
+        * @return Only available products
+        * <p>
+        * @throws javax.faces.view.facelets.FaceletException If anything went wrong
+        */
+       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+       public List<Product> getAllProducts () throws FacesException {
+               // Return it
+               return this.allProducts;
+       }
+
+       /**
+        * Getter for filtered product list
+        * <p>
+        * @return Filtered product list
+        */
+       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+       public List<Product> getFilteredProducts () {
+               return this.filteredProducts;
+       }
+
+       /**
+        * Setter for filtered product list
+        * <p>
+        * @param filteredProducts Filtered product list
+        */
+       @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
+       public void setFilteredProducts (final List<Product> 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<Product> 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<Cache.Entry<Long, Product>> iterator = this.productCache.iterator();
+
+                       // Build up list
+                       while (iterator.hasNext()) {
+                               // GEt next element
+                               final Cache.Entry<Long, Product> next = iterator.next();
+
+                               // Add to list
+                               this.getAllProducts().add(next.getValue());
+                       }
+
+                       // Sort list
+                       this.getAllProducts().sort(new Comparator<Product>() {
+                               @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 (file)
index 0000000..dca6068
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+ */
+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
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsProductListWebViewController extends Serializable {
+
+       /**
+        * Returns a product instance (entity) for given primary key. If not found,
+        * a proper exception is thrown.
+        * <p>
+        * @param productId Product id (primary key)
+        * <p>
+        * @return Product entity matching to primary key
+        * <p>
+        * @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.
+        * <p>
+        * @param productI18nKey Product i18n key
+        * <p>
+        * @return Whether the i18n key has been used
+        */
+       boolean isProductI18nKeyAdded (final String productI18nKey);
+
+}
index 65f0940c999b23e6140636a8466a5c8ee8aef038..4637505afeb9f0290e9c558fa63b5999fe48ff20 100644 (file)
@@ -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
         * <p>
-        * @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
         * <p>
-        * @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
         * <p>
-        * @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
         * <p>
-        * @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;
        }
 
        /**
index 20d51e3bcb13d227bc57c2e94ea8de18f3f68f3b..fa7c93c1f1623d2b12613de1c34437db1607de64 100644 (file)
  */
 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<Category> 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<Long, Category> categoryCache;
-
-       /**
-        * A list of filtered categories
-        */
-       private List<Category> 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
-        * <p>
-        * @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
-        * <p>
-        * @return All categories
-        */
-       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
-       public List<Category> 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
-        * <p>
-        * @return Filtered category list
-        */
-       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
-       public List<Category> getFilteredCategories () {
-               return this.filteredCategories;
-       }
-
-       /**
-        * Setter for filtered category list
-        * <p>
-        * @param filteredCategories Filtered category list
-        */
-       @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
-       public void setFilteredCategories (final List<Category> 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<Category> 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<Cache.Entry<Long, Category>> iterator = this.categoryCache.iterator();
-
-                       // Build up list
-                       while (iterator.hasNext()) {
-                               // GEt next element
-                               final Cache.Entry<Long, Category> next = iterator.next();
-
-                               // Add to list
-                               this.allCategories.add(next.getValue());
-                       }
-
-                       // Sort list
-                       this.allCategories.sort(new Comparator<Category>() {
-                               @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;
        }
 
 }
index 780f02e60485ef4a5eeba4f7bf937c0aed944d8a..4522115d0b967581b8e5eb0cf5994497d59ae8b9 100644 (file)
@@ -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.
-        * <p>
-        * @param categoryId Category id (primary key)
-        * <p>
-        * @return Category entity matching to primary key
-        * <p>
-        * @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.
-        * <p>
-        * @param categoryI18nKey Category i18n key
-        * <p>
-        * @return Whether i18n key is already added
-        * <p>
-        */
-       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 (file)
index 0000000..3f7aac1
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+ */
+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
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@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<Category> 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<Long, Category> categoryCache;
+
+       /**
+        * A list of filtered categories
+        */
+       private List<Category> 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
+        * <p>
+        * @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
+        * <p>
+        * @return All categories
+        */
+       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+       public List<Category> getAllCategories () {
+               // Return it
+               return this.allCategories;
+       }
+
+       /**
+        * Getter for filtered category list
+        * <p>
+        * @return Filtered category list
+        */
+       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+       public List<Category> getFilteredCategories () {
+               return this.filteredCategories;
+       }
+
+       /**
+        * Setter for filtered category list
+        * <p>
+        * @param filteredCategories Filtered category list
+        */
+       @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
+       public void setFilteredCategories (final List<Category> 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<Category> 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<Cache.Entry<Long, Category>> iterator = this.categoryCache.iterator();
+
+                       // Build up list
+                       while (iterator.hasNext()) {
+                               // GEt next element
+                               final Cache.Entry<Long, Category> next = iterator.next();
+
+                               // Add to list
+                               this.allCategories.add(next.getValue());
+                       }
+
+                       // Sort list
+                       this.allCategories.sort(new Comparator<Category>() {
+                               @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 (file)
index 0000000..69ea389
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+ */
+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
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsCategoryListWebViewController extends Serializable {
+
+       /**
+        * Returns a category instance (entity) for given primary key. If not found,
+        * a proper exception is thrown.
+        * <p>
+        * @param categoryId Category id (primary key)
+        * <p>
+        * @return Category entity matching to primary key
+        * <p>
+        * @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.
+        * <p>
+        * @param categoryI18nKey Category i18n key
+        * <p>
+        * @return Whether i18n key is already added
+        * <p>
+        */
+       boolean isCategoryI18nKeyAdded (final String categoryI18nKey);
+
+}
index ee8024f694d475759be209296e17af2e2c00fb29..f0130664be829c9ac818fbcc6685a6717be84445 100644 (file)
@@ -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> {
        /**
         * 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<Product> {
                        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);
index bf167ab74c63d977152746febf28a67a1f488407..c443dbad5f84863f4b620d52e16c2f0393cbc7ee 100644 (file)
@@ -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> {
        /**
         * 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<Category> {
                        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);
index 8d30c5ed8b8e490e73f3bdf7ee297ba826161788..6d165c2f7e83efe9a482c1b601960d4525892a0b 100644 (file)
@@ -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);
 
index 79477ecab14f6bab64003fee62abd410c08dacd6..3c86937e143a8685d8e550fd5f88debd697cf615 100644 (file)
@@ -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);
 
index 4dfc54476d0e9f09b59d1d598185b79577784045..c94e106fb05d1e9907e9d7878d20e6cb673472ab 100644 (file)
@@ -6,7 +6,7 @@
        xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
        xmlns:p="http://primefaces.org/ui">
 
-       <p:panelGrid layout="grid" columns="3" columnClasses="ui-grid-col-5,ui-grid-col-2,ui-grid-col-5" styleClass="table table-full ui-noborder" rendered="#{empty rendered or rendered == true}">
+       <p:panelGrid layout="grid" columns="3" columnClasses="ui-grid-col-3,ui-grid-col-2,ui-grid-col-3" styleClass="table table-full ui-noborder" rendered="#{empty rendered or rendered == true}">
                <p:outputLabel for="productNetPrice" value="#{project.ENTER_NET_PRICE}" />
 
                <p:outputLabel for="productTaxRate" value="#{project.ENTER_TAX_RATE}" />
index d24cea0e370287e481ef72129b8a016daa865b2a..92020f1f32102754fa1c68d6999f3107355b6ee2 100644 (file)
@@ -23,7 +23,7 @@
                                >
                                <f:converter converterId="ProductCategoryConverter" />
                                <f:selectItem itemValue="#{null}" itemLabel="#{msg.PLEASE_SELECT}" noSelectionOption="true" itemDisabled="true" />
-                               <f:selectItems value="#{categoryController.allCategories()}" var="category" itemValue="#{category}" itemLabel="#{beanHelper.renderProductCategory(category)}" />
+                               <f:selectItems value="#{categoryListController.allCategories}" var="category" itemValue="#{category}" itemLabel="#{beanHelper.renderProductCategory(category)}" />
                        </p:selectOneMenu>
 
                        <p:outputLabel for="productI18nKey" value="#{project.ADMIN_ENTER_GENERIC_PRODUCT_I18N_KEY}" />
@@ -80,7 +80,7 @@
                                >
                                <f:converter converterId="BasicCompanyDataConverter" />
                                <f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
-                               <f:selectItems value="#{basicCompanyDataController.allBasicData()}" var="basicData" itemValue="#{basicData}" itemLabel="#{basicData.companyName}" />
+                               <f:selectItems value="#{basicDataListController.allBasicData}" var="basicData" itemValue="#{basicData}" itemLabel="#{basicData.companyName}" />
                        </p:selectOneMenu>
 
                        <p:outputLabel for="productAvailability" value="#{project.ADMIN_ENABLE_PRODUCT_AVAILABILITY}" />
index 5360ca07651be6137213d8c1487014369188fa5f..65dbfd42c2e4cace5cf16a4ef4f620d815c62b30 100644 (file)
@@ -20,7 +20,7 @@
                                >
                                <f:converter converterId="ProductCategoryConverter" />
                                <f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
-                               <f:selectItems value="#{categoryController.allCategories()}" var="category" itemValue="#{category}" itemLabel="#{beanHelper.renderProductCategory(category)}" />
+                               <f:selectItems value="#{categoryListController.allCategories}" var="category" itemValue="#{category}" itemLabel="#{beanHelper.renderProductCategory(category)}" />
                        </p:selectOneMenu>
 
                        <p:outputLabel for="categoryI18nKey" value="#{project.ADMIN_ENTER_CATEGORY_I18N_KEY}" />
index 5cd8d7e0bd3c26bf32459977e3a82f100e0f627a..973c5d18dff1f513b5ed5518927627d535eedc09 100644 (file)
        </ui:define>
 
        <ui:define name="content">
+               <h4>
+                       <h:outputText value="#{project.ADMIN_LIST_GENERIC_PRODUCTS_HEADER}" />
+               </h4>
+
                <h:form id="form-list-products">
                        <p:dataTable
-                               id="table-list-products"
+                               id="productList"
                                var="product"
-                               value="#{productController.allProducts()}"
+                               value="#{productListController.allProducts}"
                                tableStyleClass="table table-full"
                                paginator="true"
                                paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
-                               filteredValue="#{productController.filteredProducts}"
+                               filteredValue="#{productListController.filteredProducts}"
                                rows="10"
+                               rowKey="#{product.productId}"
                                reflow="true"
                                resizableColumns="true"
                                rowsPerPageTemplate="5,10,20,50,100"
                                >
 
                                <f:facet name="header">
-                                       <p:panelGrid columns="2" columnClasses="ui-grid-col-10,ui-grid-col-2" layout="grid" styleClass="ui-noborder ui-transparent-widget">
-                                               <h:outputText value="#{project.ADMIN_LIST_GENERIC_PRODUCTS_HEADER}" />
+                                       <p:panelGrid columns="3" layout="grid" columnClasses="ui-grid-col-4,ui-grid-col-6,ui-grid-col-2">
+                                               <p:spacer />
+
+                                               <p:panelGrid columns="2" columnClasses="ui-grid-4,ui-grid-8" layout="grid" styleClass="table table-full ui-noborder">
+                                                       <p:outputLabel for="globalFilter" value="#{msg.SEARCH_ALL_FIELDS}" style="float: right" />
+                                                       <p:inputText id="globalFilter" onkeyup="PF('productList').filter()" placeholder="#{msg.ENTER_KEYWORD}"/>
+                                               </p:panelGrid>
 
-                                               <h:panelGroup>
+                                               <p:outputPanel>
+                                                       <p:spacer height="4" />
                                                        <p:commandButton id="toggler" type="button" value="#{msg.SELECT_SHOWN_COLUMNS}" styleClass="column-selector" />
-                                                       <p:columnToggler datasource="table-list-products" trigger="toggler" />
-                                               </h:panelGroup>
+                                                       <p:columnToggler datasource="productList" trigger="toggler" />
+                                               </p:outputPanel>
                                        </p:panelGrid>
                                </f:facet>
 
@@ -53,7 +64,7 @@
                                        </p:link>
                                </p:column>
 
-                               <p:column headerText="#{msg.ADMIN_HEADER_I18N_KEY}" sortBy="#{product.productI18nKey}" filterBy="#{product.productI18nKey}" filterMatchMode="contains">
+                               <p:column headerText="#{msg.ADMIN_HEADER_I18N_KEY}" sortBy="#{product.productI18nKey}" filterBy="#{product.productI18nKey}">
                                        <h:outputText value="#{local[product.productI18nKey]}" title="#{product.productI18nKey}" />
                                </p:column>
 
@@ -68,8 +79,7 @@
                                                        title="#{project.FILTER_BY_MULTIPLE_PRODUCT_CATEGORIES_TITLE}"
                                                        >
                                                        <f:converter converterId="ProductCategoryConverter" />
-                                                       <f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
-                                                       <f:selectItems value="#{categoryController.allCategories()}" var="category" itemValue="#{category}" itemLabel="#{beanHelper.renderProductCategory(category)}" />
+                                                       <f:selectItems value="#{categoryListController.allCategories}" var="category" itemValue="#{category}" itemLabel="#{beanHelper.renderProductCategory(category)}" />
                                                </p:selectCheckboxMenu>
                                        </f:facet>
 
                                        </p:link>
                                </p:column>
 
-                               <p:column headerText="#{project.ADMIN_HEADER_PRODUCT_GROSS_PRICE}" sortBy="#{product.productGrossPrice}" filterBy="#{product.productGrossPrice}" filterMatchMode="in">
+                               <p:column headerText="#{project.ADMIN_HEADER_PRODUCT_GROSS_PRICE}" sortBy="#{product.productGrossPrice}" filterBy="#{product.productGrossPrice}" filterFunction="#{productListController.filterByPrice}">
                                        <h:outputText value="#{product.productGrossPrice}">
                                                <!-- @TODO Hard-coded EUR again -->
                                                <f:convertNumber type="currency" currencyCode="EUR" />
                                        </h:outputText>
                                </p:column>
 
-                               <p:column headerText="#{project.ADMIN_HEADER_PRODUCT_AVAILABILITY}" sortBy="#{product.productAvailability}" filterBy="#{product.productAvailability}" filterMatchMode="equals">
+                               <p:column headerText="#{project.ADMIN_HEADER_PRODUCT_AVAILABILITY}" sortBy="#{product.productAvailability}" filterBy="#{product.productAvailability}" filterMatchMode="exact">
                                        <f:facet name="filter">
                                                <p:selectOneMenu onchange="PF('productList').filter()">
                                                        <f:converter converterId="javax.faces.Boolean" />
-                                                       <f:selectItem itemLabel="#{msg.CHOICE_ALL}" itemValue="" />
+                                                       <f:selectItem itemLabel="#{msg.CHOICE_ALL}" itemValue="#{null}" />
                                                        <f:selectItem itemLabel="#{msg.CHOICE_YES}" itemValue="true" />
                                                        <f:selectItem itemLabel="#{msg.CHOICE_NO}" itemValue="false" />
                                                </p:selectOneMenu>
                                                        title="#{msg.FILTER_BY_MULTIPLE_COMPANIES_TITLE}"
                                                        >
                                                        <f:converter converterId="BasicCompanyDataConverter" />
-                                                       <f:selectItems value="#{basicCompanyDataController.allBasicData()}" var="basicData" itemValue="#{basicData}" itemLabel="#{basicData.companyName}" />
+                                                       <f:selectItems value="#{basicDataListController.allBasicData}" var="basicData" itemValue="#{basicData}" itemLabel="#{basicData.companyName}" />
                                                </p:selectCheckboxMenu>
                                        </f:facet>
 
                                                        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"
                                                        />
                                        </p:panelGrid>
                                </f:facet>
index 74bc2ac6d30dcf617308cb8aecabfdd4723ae2ec..44f7668ffaacb90ab1c7dc36f4d6c70279fe31b8 100644 (file)
@@ -18,9 +18,9 @@
        <ui:define name="content">
                <h:form id="form-list-categories">
                        <p:dataTable
-                               id="table-list-categories"
+                               id="categoryList"
                                var="category"
-                               value="#{categoryController.allCategories()}"
+                               value="#{categoryListController.allCategories}"
                                tableStyleClass="table table-full"
                                paginator="true"
                                paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
@@ -41,7 +41,7 @@
 
                                                <h:panelGroup>
                                                        <p:commandButton id="toggler" type="button" value="#{msg.SELECT_SHOWN_COLUMNS}" styleClass="column-selector" />
-                                                       <p:columnToggler datasource="table-list-categories" trigger="toggler" />
+                                                       <p:columnToggler datasource="categoryList" trigger="toggler" />
                                                </h:panelGroup>
                                        </p:panelGrid>
                                </f:facet>
@@ -68,7 +68,7 @@
                                                        >
                                                        <f:converter converterId="ProductCategoryConverter" />
                                                        <f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
-                                                       <f:selectItems value="#{categoryController.allCategories()}" var="category" itemValue="#{category}" itemLabel="#{beanHelper.renderProductCategory(category)}" />
+                                                       <f:selectItems value="#{categoryListController.allCategories}" var="category" itemValue="#{category}" itemLabel="#{beanHelper.renderProductCategory(category)}" />
                                                </p:selectCheckboxMenu>
                                        </f:facet>
 
                                                        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"
                                                        />
                                        </p:panelGrid>
                                </f:facet>