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;
*/
private Category productCategory;
- /**
- * General product controller
- */
- @Inject
- private FinancialProductWebRequestController productController;
-
/**
* Product's price currency code like EUR or USD
*/
*/
private String productI18nKey;
+ /**
+ * Product list controller
+ */
+ @Inject
+ private FinancialsProductListWebViewController productListController;
+
/**
* Product's manufacturing/producing company
*/
*/
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.");
}
*/
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
*/
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;
}
}
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
@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;
-
}
--- /dev/null
+/*
+ * 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;
+ }
+
+}
--- /dev/null
+/*
+ * 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);
+
+}
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;
@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
*/
*/
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.");
}
}
/**
- * 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;
}
/**
*/
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
*/
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;
}
}
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
*/
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);
-
}
--- /dev/null
+/*
+ * 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;
+ }
+
+}
--- /dev/null
+/*
+ * 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);
+
+}
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;
/**
* 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?
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);
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;
/**
* 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?
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);
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
/**
* Backing bean for product categories
*/
- private static FinancialProductWebRequestController PRODUCT_CONTROLLER;
+ private static FinancialsProductListWebViewController PRODUCT_LIST_CONTROLLER;
/**
* Serial number
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);
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
/**
* Backing bean for product categories
*/
- private static FinancialCategoryWebRequestController CATEGORY_CONTROLLER;
+ private static FinancialsCategoryListWebViewController CATEGORY_LIST_CONTROLLER;
/**
* Serial number
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);
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}" />
>
<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}" />
>
<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}" />
>
<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}" />
</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>
</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>
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>
<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}"
<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>
>
<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>