From 9ba612c7e5bffb749274c3b0c2b2be6644eed3b1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 13 Dec 2018 22:40:35 +0100 Subject: [PATCH] Product-only: - converted ui:include template admin_form_product_data.tpl to custom JSF tag product:genericProductForm - introduced view-scoped action backing bean for Product entity which hold code from request-scoped backing bean, this is required to have edit/delete/show views working again - removed beanProductHelper.product property and notifyControllerProductConverted() in favor of copyAllProductProperties() - renamed some language strings MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../FinancialAdminProductWebRequestBean.java | 130 +--- ...lAdminGenericProductActionWebViewBean.java | 571 ++++++++++++++++++ ...alAdminProductActionWebViewController.java | 29 + .../FinancialsProductWebViewHelperBean.java | 57 -- .../FinancialAdminCategoryWebRequestBean.java | 4 +- .../FinancialsCategoryListWebViewBean.java | 2 +- web/WEB-INF/product.jsf.taglib.xml | 12 + .../admin_form_generic_product_data.tpl} | 54 +- .../admin_form_category_data.tpl | 10 +- .../admin_generic_product_delete.xhtml | 15 +- .../admin_generic_product_edit.xhtml | 37 +- .../admin_generic_product_list.xhtml | 32 +- .../admin_generic_product_show.xhtml | 15 +- .../admin_product_category_list.xhtml | 15 +- 14 files changed, 758 insertions(+), 225 deletions(-) create mode 100644 src/java/org/mxchange/jfinancials/beans/generic_product/action/FinancialAdminGenericProductActionWebViewBean.java create mode 100644 src/java/org/mxchange/jfinancials/beans/generic_product/action/FinancialAdminProductActionWebViewController.java rename web/WEB-INF/{templates/admin/generic_product/admin_form_product_data.tpl => resources/tags/forms/generic_product/admin_form_generic_product_data.tpl} (79%) diff --git a/src/java/org/mxchange/jfinancials/beans/generic_product/FinancialAdminProductWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/generic_product/FinancialAdminProductWebRequestBean.java index 29444edd..c60efe1f 100644 --- a/src/java/org/mxchange/jfinancials/beans/generic_product/FinancialAdminProductWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/generic_product/FinancialAdminProductWebRequestBean.java @@ -17,11 +17,9 @@ package org.mxchange.jfinancials.beans.generic_product; import java.math.BigDecimal; -import java.text.MessageFormat; import javax.ejb.EJB; import javax.enterprise.context.RequestScoped; import javax.enterprise.event.Event; -import javax.enterprise.event.Observes; import javax.enterprise.inject.Any; import javax.faces.view.facelets.FaceletException; import javax.inject.Inject; @@ -31,11 +29,7 @@ import org.mxchange.jfinancials.beans.BaseFinancialsBean; import org.mxchange.jfinancials.beans.generic_product.list.FinancialsProductListWebViewController; import org.mxchange.jproduct.events.product.added.AddedProductEvent; import org.mxchange.jproduct.events.product.added.ProductAddedEvent; -import org.mxchange.jproduct.events.product.created.ObservableCreatedProductEvent; -import org.mxchange.jproduct.events.product.updated.ObservableProductUpdatedEvent; -import org.mxchange.jproduct.events.product.updated.ProductUpdatedEvent; import org.mxchange.jproduct.exceptions.product.ProductAlreadyAddedException; -import org.mxchange.jproduct.exceptions.product.ProductNotFoundException; import org.mxchange.jproduct.model.category.Category; import org.mxchange.jproduct.model.product.AdminProductSessionBeanRemote; import org.mxchange.jproduct.model.product.GenericProduct; @@ -47,7 +41,7 @@ import org.mxchange.jproduct.model.product.agegroup.AgeGroup; *

* @author Roland Häder */ -@Named ("adminProductController") +@Named ("adminGenericProductController") @RequestScoped public class FinancialAdminProductWebRequestBean extends BaseFinancialsBean implements FinancialAdminProductWebRequestController { @@ -150,13 +144,6 @@ public class FinancialAdminProductWebRequestBean extends BaseFinancialsBean impl */ private String productUnitI18nKey; - /** - * Event for updated product - */ - @Inject - @Any - private Event updatedProductEvent; - /** * Default constructor */ @@ -193,51 +180,6 @@ public class FinancialAdminProductWebRequestBean extends BaseFinancialsBean impl // Fire event this.addedProductEvent.fire(new ProductAddedEvent(updatedProduct)); - - // Set all to null - this.clear(); - } - - /** - * Observer for events being fired when a bean helper has successfully - * created a product instance. - *

- * @param event Event being fired - */ - public void afterCreatedProductEvent (@Observes final ObservableCreatedProductEvent event) { - // The event instance must be valid - if (null == event) { - // Throw NPE again - throw new NullPointerException("event is null"); //NOI18N - } else if (event.getCreatedProduct() == null) { - // Throw NPE again - throw new NullPointerException("event.createdProduct is null"); //NOI18N //NOI18N - } else if (event.getCreatedProduct().getProductId() == null) { - // Throw NPE again - throw new NullPointerException("event.createdProduct.productId is null"); //NOI18N //NOI18N - } else if (event.getCreatedProduct().getProductId() < 1) { - // Not valid - throw new IllegalStateException(MessageFormat.format("event.createdProduct.productId={0} is not valid.", event.getCreatedProduct().getProductId())); //NOI18N - } - - // Get product instance from event - final Product product = event.getCreatedProduct(); - - // Set all fields - this.setProductAgeGroup(product.getProductAgeGroup()); - this.setProductAvailability(product.getProductAvailability()); - this.setProductCategory(product.getProductCategory()); - this.setProductCurrencyCode(product.getProductCurrencyCode()); - this.setProductGrossPrice(product.getProductGrossPrice()); - this.setProductI18nKey(product.getProductI18nKey()); - this.setProductId(product.getProductId()); - this.setProductManufacturer(product.getProductManufacturer()); - this.setProductNetPrice(product.getProductNetPrice()); - this.setProductNumber(product.getProductNumber()); - this.setProductSize(product.getProductSize()); - this.setProductTaxRate(product.getProductTaxRate()); - this.setProductUnitAmount(product.getProductUnitAmount()); - this.setProductUnitI18nKey(product.getProductUnitI18nKey()); } /** @@ -510,66 +452,6 @@ public class FinancialAdminProductWebRequestBean extends BaseFinancialsBean impl this.productUnitI18nKey = productUnitI18nKey; } - /** - * Updates given product data from request to database - *

- * @throws FaceletException If something unexpected happened - */ - public void updateProduct () throws FaceletException { - // Get product instance - final Product product = this.createProductInstance(); - // Check if product instance is in helper and valid - - if (null == product) { - // Throw NPE - throw new NullPointerException("productBeanHelper.product is null"); //NOI18N - } else if (product.getProductId() == null) { - // Throw NPE again - throw new NullPointerException("productBeanHelper.product.productId is null"); //NOI18N //NOI18N - } else if (product.getProductId() < 1) { - // Invalid id - throw new IllegalStateException(MessageFormat.format("productBeanHelper.product.productId={0} is invalid", product.getProductId())); //NOI18N - } - - // Init productr - final Product updatedProduct; - - try { - // Call EJB for updating product data - updatedProduct = this.adminProductBean.updateProductData(product); - } catch (final ProductNotFoundException ex) { - // Throw again - throw new FaceletException(ex); - } - - // Fire event - this.updatedProductEvent.fire(new ProductUpdatedEvent(updatedProduct)); - - // Clear bean - this.clear(); - } - - /** - * Clears this bean (example: product has been added) - */ - private void clear () { - // Clear all data - this.setProductAgeGroup(null); - this.setProductAvailability(Boolean.FALSE); - this.setProductBarCodeNumber(null); - this.setProductCategory(null); - this.setProductGrossPrice(null); - this.setProductI18nKey(null); - this.setProductId(null); - this.setProductManufacturer(null); - this.setProductNetPrice(null); - this.setProductNumber(null); - this.setProductSize(null); - this.setProductTaxRate(null); - this.setProductUnitAmount(null); - this.setProductUnitI18nKey(null); - } - /** * Creates a product instance with all fields *

@@ -577,7 +459,15 @@ public class FinancialAdminProductWebRequestBean extends BaseFinancialsBean impl */ private Product createProductInstance () { // Create product instance - final Product product = new GenericProduct(this.getProductI18nKey(), this.getProductGrossPrice(), this.getProductCurrencyCode(), this.getProductCategory(), this.getProductAvailability(), this.getProductUnitAmount(), this.getProductUnitI18nKey()); + final Product product = new GenericProduct( + this.getProductI18nKey(), + this.getProductGrossPrice(), + this.getProductCurrencyCode(), + this.getProductCategory(), + this.getProductAvailability(), + this.getProductUnitAmount(), + this.getProductUnitI18nKey() + ); // Set all optional fields product.setProductAgeGroup(this.getProductAgeGroup()); diff --git a/src/java/org/mxchange/jfinancials/beans/generic_product/action/FinancialAdminGenericProductActionWebViewBean.java b/src/java/org/mxchange/jfinancials/beans/generic_product/action/FinancialAdminGenericProductActionWebViewBean.java new file mode 100644 index 00000000..a7c1f30a --- /dev/null +++ b/src/java/org/mxchange/jfinancials/beans/generic_product/action/FinancialAdminGenericProductActionWebViewBean.java @@ -0,0 +1,571 @@ +/* + * Copyright (C) 2016 - 2018 Free Software Foundation + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.mxchange.jfinancials.beans.generic_product.action; + +import java.math.BigDecimal; +import java.text.MessageFormat; +import javax.ejb.EJB; +import javax.enterprise.event.Event; +import javax.enterprise.inject.Any; +import javax.faces.view.ViewScoped; +import javax.faces.view.facelets.FaceletException; +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.updated.ObservableProductUpdatedEvent; +import org.mxchange.jproduct.events.product.updated.ProductUpdatedEvent; +import org.mxchange.jproduct.exceptions.product.ProductNotFoundException; +import org.mxchange.jproduct.model.category.Category; +import org.mxchange.jproduct.model.product.AdminProductSessionBeanRemote; +import org.mxchange.jproduct.model.product.GenericProduct; +import org.mxchange.jproduct.model.product.Product; +import org.mxchange.jproduct.model.product.agegroup.AgeGroup; + +/** + * Main application class + *

+ * @author Roland Häder + */ +@Named ("adminGenericProductActionController") +@ViewScoped +public class FinancialAdminGenericProductActionWebViewBean extends BaseFinancialsBean implements FinancialAdminProductActionWebViewController { + + /** + * Serial number + */ + private static final long serialVersionUID = 5_819_375_183_472_872L; + + /** + * Remote bean for products + */ + @EJB (lookup = "java:global/jfinancials-ejb/adminProduct!org.mxchange.jproduct.model.product.AdminProductSessionBeanRemote") + private AdminProductSessionBeanRemote adminProductBean; + + /** + * Product instance + */ + private Product product; + + /** + * Product's age group + */ + private AgeGroup productAgeGroup; + + /** + * Availability + */ + private Boolean productAvailability; + + /** + * Barcode number + */ + private String productBarCodeNumber; + + /** + * Category instance + */ + private Category productCategory; + + /** + * Product's price currency code like EUR or USD + */ + private String productCurrencyCode; + + /** + * Product's gross price + */ + private BigDecimal productGrossPrice; + + /** + * I18n key of product + */ + private String productI18nKey; + + /** + * Product id + */ + private Long productId; + + /** + * Product list controller + */ + @Inject + private FinancialsProductListWebViewController productListController; + + /** + * Product's manufacturing/producing company + */ + private BasicData productManufacturer; + + /** + * Product's net price + */ + private BigDecimal productNetPrice; + + /** + * Product number + */ + private Long productNumber; + + /** + * Product size (for shoes, clothings) + */ + private String productSize; + + /** + * Product's tax rate + */ + private BigDecimal productTaxRate; + + /** + * Product's unit amount + */ + private BigDecimal productUnitAmount; + + /** + * Product's i18n key + */ + private String productUnitI18nKey; + + /** + * Event for updated product + */ + @Inject + @Any + private Event updatedProductEvent; + + /** + * Default constructor + */ + public FinancialAdminGenericProductActionWebViewBean () { + // Call super constructor + super(); + } + + /** + * Copies all product's properties back to this bean. + */ + public void copyAllProductProperties () { + // Validate product instance + if (this.getProduct() == null) { + // Throw NPE + throw new NullPointerException("this.product is null"); //NOI18N + } else if (this.getProduct().getProductId() == null) { + // Throw NPE again + throw new NullPointerException("this.product.productId is null"); //NOI18N + } else if (this.getProduct().getProductId() < 1) { + // Not valid + throw new IllegalStateException(MessageFormat.format("this.product.productId={0} is not valid.", this.getProduct().getProductId())); //NOI18N + } + + // Now copy all fields + this.setProductAgeGroup(this.getProduct().getProductAgeGroup()); + this.setProductAvailability(this.getProduct().getProductAvailability()); + this.setProductBarCodeNumber(this.getProduct().getProductBarCodeNumber()); + this.setProductCategory(this.getProduct().getProductCategory()); + this.setProductCurrencyCode(this.getProduct().getProductCurrencyCode()); + this.setProductGrossPrice(this.getProduct().getProductGrossPrice()); + this.setProductI18nKey(this.getProduct().getProductI18nKey()); + this.setProductId(this.getProduct().getProductId()); + this.setProductManufacturer(this.getProduct().getProductManufacturer()); + this.setProductNetPrice(this.getProduct().getProductNetPrice()); + this.setProductNumber(this.getProduct().getProductNumber()); + this.setProductSize(this.getProduct().getProductSize()); + this.setProductTaxRate(this.getProduct().getProductTaxRate()); + this.setProductUnitAmount(this.getProduct().getProductUnitAmount()); + this.setProductUnitI18nKey(this.getProduct().getProductUnitI18nKey()); + } + + /** + * Getter for product instance + *

+ * @return Product instance + */ + public Product getProduct () { + return this.product; + } + + /** + * Setter for product instance + *

+ * @param product Product instance + */ + public void setProduct (final Product product) { + this.product = product; + } + + /** + * Getter for product's age group + *

+ * @return Product's age group + */ + public AgeGroup getProductAgeGroup () { + return this.productAgeGroup; + } + + /** + * Setter for product's age group + *

+ * @param productAgeGroup Product's age group + */ + public void setProductAgeGroup (final AgeGroup productAgeGroup) { + this.productAgeGroup = productAgeGroup; + } + + /** + * Getter for product's available + *

+ * @return Product's available + */ + public Boolean getProductAvailability () { + return this.productAvailability; + } + + /** + * Setter for product's available + *

+ * @param productAvailability Product's available + */ + public void setProductAvailability (final Boolean productAvailability) { + this.productAvailability = productAvailability; + } + + /** + * Getter for product's bar-code number + *

+ * @return Product's bar-code number + */ + public String getProductBarCodeNumber () { + return this.productBarCodeNumber; + } + + /** + * Setter for product's bar-code number + *

+ * @param productBarCodeNumber Product's bar-code number + */ + public void setProductBarCodeNumber (final String productBarCodeNumber) { + this.productBarCodeNumber = productBarCodeNumber; + } + + /** + * Getter for product's category + *

+ * @return Product's category + */ + public Category getProductCategory () { + return this.productCategory; + } + + /** + * Setter for product's category instance + *

+ * @param productCategory Product's category instance + */ + public void setProductCategory (final Category productCategory) { + this.productCategory = productCategory; + } + + /** + * Getter for product's price currency code + *

+ * @return Product's price currency code + */ + public String getProductCurrencyCode () { + return this.productCurrencyCode; + } + + /** + * Setter for product's price currency code + *

+ * @param productCurrencyCode Product's price currency code + */ + public void setProductCurrencyCode (final String productCurrencyCode) { + this.productCurrencyCode = productCurrencyCode; + } + + /** + * Getter for product's gross price + *

+ * @return Product's gross price + */ + public BigDecimal getProductGrossPrice () { + return this.productGrossPrice; + } + + /** + * Setter for product's gross price + *

+ * @param productGrossPrice Product's gross price + */ + public void setProductGrossPrice (final BigDecimal productGrossPrice) { + this.productGrossPrice = productGrossPrice; + } + + /** + * Getter for product unit's i18n key + *

+ * @return Product's i18n key + */ + public String getProductI18nKey () { + return this.productI18nKey; + } + + /** + * Setter for product unit's i18n key + *

+ * @param productI18nKey Product's i18n key + */ + public void setProductI18nKey (final String productI18nKey) { + this.productI18nKey = productI18nKey; + } + + /** + * Getter for product id + *

+ * @return Product id + */ + public Long getProductId () { + return this.productId; + } + + /** + * Setter for product id + *

+ * @param productId Product id + */ + public void setProductId (final Long productId) { + this.productId = productId; + } + + /** + * Getter for product's manufacturing/producing company + *

+ * @return Product's manufacturing/producing company + */ + public BasicData getProductManufacturer () { + return this.productManufacturer; + } + + /** + * Setter for product's manufacturing/producing company + *

+ * @param productManufacturer Product's manufacturing/producing company + */ + public void setProductManufacturer (final BasicData productManufacturer) { + this.productManufacturer = productManufacturer; + } + + /** + * Getter for product's net price + *

+ * @return Product's net price + */ + public BigDecimal getProductNetPrice () { + return this.productNetPrice; + } + + /** + * Setter for product's net price + *

+ * @param productNetPrice Product's net price + */ + public void setProductNetPrice (final BigDecimal productNetPrice) { + this.productNetPrice = productNetPrice; + } + + /** + * Getter for product's number + *

+ * @return Product's number + */ + public Long getProductNumber () { + return this.productNumber; + } + + /** + * Setter for product's number + *

+ * @param productNumber Product's number + */ + public void setProductNumber (final Long productNumber) { + this.productNumber = productNumber; + } + + /** + * Getter for product's size + *

+ * @return Product's size + */ + public String getProductSize () { + return this.productSize; + } + + /** + * Setter for product's size + *

+ * @param productSize Product's size + */ + public void setProductSize (final String productSize) { + this.productSize = productSize; + } + + /** + * Getter for product's tax rate + *

+ * @return Product's tax rate + */ + public BigDecimal getProductTaxRate () { + return this.productTaxRate; + } + + /** + * Setter for product's tax rate + *

+ * @param productTaxRate Product's tax rate + */ + public void setProductTaxRate (final BigDecimal productTaxRate) { + this.productTaxRate = productTaxRate; + } + + /** + * Getter for product's unit amount + *

+ * @return Product's unit amount + */ + public BigDecimal getProductUnitAmount () { + return this.productUnitAmount; + } + + /** + * Setter for product's unit amount + *

+ * @param productUnitAmount Product's unit amount + */ + public void setProductUnitAmount (final BigDecimal productUnitAmount) { + this.productUnitAmount = productUnitAmount; + } + + /** + * Getter for product unit's i18n key + *

+ * @return Product's i18n key + */ + public String getProductUnitI18nKey () { + return this.productUnitI18nKey; + } + + /** + * Setter for product unit's i18n key + *

+ * @param productUnitI18nKey Product unit's i18n key + */ + public void setProductUnitI18nKey (final String productUnitI18nKey) { + this.productUnitI18nKey = productUnitI18nKey; + } + + /** + * Updates given product data from request to database + *

+ * @throws FaceletException If something unexpected happened + */ + public void updateProduct () throws FaceletException { + // Get product instance + final Product newProduct = this.createProductInstance(); + // Check if product instance is in helper and valid + + if (null == newProduct) { + // Throw NPE + throw new NullPointerException("newProduct is null"); //NOI18N + } else if (newProduct.getProductId() == null) { + // Throw NPE again + throw new NullPointerException("newProduct.productId is null"); //NOI18N //NOI18N + } else if (newProduct.getProductId() < 1) { + // Invalid id + throw new IllegalStateException(MessageFormat.format("newProduct.productId={0} is invalid", newProduct.getProductId())); //NOI18N + } + + // Init productr + final Product updatedProduct; + + try { + // Call EJB for updating product data + updatedProduct = this.adminProductBean.updateProductData(newProduct); + } catch (final ProductNotFoundException ex) { + // Throw again + throw new FaceletException(ex); + } + + // Fire event + this.updatedProductEvent.fire(new ProductUpdatedEvent(updatedProduct)); + + // Clear bean + this.clear(); + } + + /** + * Clears this bean (example: product has been added) + */ + private void clear () { + // Clear all data + this.setProductAgeGroup(null); + this.setProductAvailability(Boolean.FALSE); + this.setProductBarCodeNumber(null); + this.setProductCategory(null); + this.setProductGrossPrice(null); + this.setProductI18nKey(null); + this.setProductId(null); + this.setProductManufacturer(null); + this.setProductNetPrice(null); + this.setProductNumber(null); + this.setProductSize(null); + this.setProductTaxRate(null); + this.setProductUnitAmount(null); + this.setProductUnitI18nKey(null); + } + + /** + * Creates a product instance with all fields + *

+ * @return Product instance + */ + private Product createProductInstance () { + // Create product instance + final Product newProduct = new GenericProduct(this.getProductI18nKey(), this.getProductGrossPrice(), this.getProductCurrencyCode(), this.getProductCategory(), this.getProductAvailability(), this.getProductUnitAmount(), this.getProductUnitI18nKey()); + + // Set all optional fields + newProduct.setProductAgeGroup(this.getProductAgeGroup()); + newProduct.setProductBarCodeNumber(this.getProductBarCodeNumber()); + newProduct.setProductManufacturer(this.getProductManufacturer()); + newProduct.setProductNumber(this.getProductNumber()); + newProduct.setProductNetPrice(this.getProductNetPrice()); + newProduct.setProductSize(this.getProductSize()); + newProduct.setProductTaxRate(this.getProductTaxRate()); + + // Is product id set? + if (this.getProductId() instanceof Long) { + // Set it, too + newProduct.setProductId(this.getProductId()); + } + + // Return it + return newProduct; + } + +} diff --git a/src/java/org/mxchange/jfinancials/beans/generic_product/action/FinancialAdminProductActionWebViewController.java b/src/java/org/mxchange/jfinancials/beans/generic_product/action/FinancialAdminProductActionWebViewController.java new file mode 100644 index 00000000..3487fb13 --- /dev/null +++ b/src/java/org/mxchange/jfinancials/beans/generic_product/action/FinancialAdminProductActionWebViewController.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2016 - 2018 Free Software Foundation + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.mxchange.jfinancials.beans.generic_product.action; + +import org.mxchange.jfinancials.beans.generic_product.*; +import java.io.Serializable; + +/** + * An interface for product controllers for "ADMIN" role + *

+ * @author Roland Häder + */ +public interface FinancialAdminProductActionWebViewController extends Serializable { + +} diff --git a/src/java/org/mxchange/jfinancials/beans/helper/product/FinancialsProductWebViewHelperBean.java b/src/java/org/mxchange/jfinancials/beans/helper/product/FinancialsProductWebViewHelperBean.java index 4e805f6a..5b55fcc9 100644 --- a/src/java/org/mxchange/jfinancials/beans/helper/product/FinancialsProductWebViewHelperBean.java +++ b/src/java/org/mxchange/jfinancials/beans/helper/product/FinancialsProductWebViewHelperBean.java @@ -16,16 +16,11 @@ */ package org.mxchange.jfinancials.beans.helper.product; -import java.text.MessageFormat; -import javax.enterprise.event.Event; -import javax.enterprise.inject.Any; import javax.faces.view.ViewScoped; import javax.inject.Inject; import javax.inject.Named; import org.mxchange.jfinancials.beans.BaseFinancialsBean; import org.mxchange.jfinancials.beans.localization.FinancialsLocalizationSessionController; -import org.mxchange.jproduct.events.product.created.CreatedProductEvent; -import org.mxchange.jproduct.events.product.created.ObservableCreatedProductEvent; import org.mxchange.jproduct.model.category.Category; import org.mxchange.jproduct.model.product.Product; @@ -49,19 +44,6 @@ public class FinancialsProductWebViewHelperBean extends BaseFinancialsBean imple @Inject private FinancialsLocalizationSessionController localizationController; - /** - * Product instance - */ - private Product product; - - /** - * An event fired when a product id has been converted to a product - * instance. - */ - @Inject - @Any - private Event productCreatedEvent; - /** * Default constructor */ @@ -70,45 +52,6 @@ public class FinancialsProductWebViewHelperBean extends BaseFinancialsBean imple super(); } - /** - * Getter for product instance - *

- * @return Product instance - */ - public Product getProduct () { - return this.product; - } - - /** - * Setter for product instance - *

- * @param product Product instance - */ - public void setProduct (final Product product) { - this.product = product; - } - - /** - * Notifies other controllers (backing beans) if a product id has been - * successfully converted to a Product instance. - */ - public void notifyControllerProductConverted () { - // Validate product instance - if (this.getProduct() == null) { - // Throw NPE - throw new NullPointerException("this.product is null"); //NOI18N - } else if (this.getProduct().getProductId() == null) { - // Throw NPE again - throw new NullPointerException("this.product.productId is null"); //NOI18N - } else if (this.getProduct().getProductId() < 1) { - // Not valid - throw new IllegalStateException(MessageFormat.format("this.product.productId={0} is not valid.", this.getProduct().getProductId())); //NOI18N - } - - // Set all fields: user - this.productCreatedEvent.fire(new CreatedProductEvent(this.getProduct())); - } - /** * Returns the product name and price. If null is provided, an empty string * is returned. diff --git a/src/java/org/mxchange/jfinancials/beans/product_category/FinancialAdminCategoryWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/product_category/FinancialAdminCategoryWebRequestBean.java index 4637505a..c427ca17 100644 --- a/src/java/org/mxchange/jfinancials/beans/product_category/FinancialAdminCategoryWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/product_category/FinancialAdminCategoryWebRequestBean.java @@ -25,8 +25,8 @@ 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.events.category.added.AddedCategoryEvent; +import org.mxchange.jproduct.events.category.added.CategoryAddedEvent; import org.mxchange.jproduct.exceptions.category.CategoryAlreadyAddedException; import org.mxchange.jproduct.model.category.AdminCategorySessionBeanRemote; import org.mxchange.jproduct.model.category.Category; 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 index ac6c29e7..46598701 100644 --- a/src/java/org/mxchange/jfinancials/beans/product_category/list/FinancialsCategoryListWebViewBean.java +++ b/src/java/org/mxchange/jfinancials/beans/product_category/list/FinancialsCategoryListWebViewBean.java @@ -31,7 +31,7 @@ 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.events.category.added.AddedCategoryEvent; import org.mxchange.jproduct.exceptions.category.CategoryNotFoundException; import org.mxchange.jproduct.model.category.Category; import org.mxchange.jproduct.model.category.CategorySessionBeanRemote; diff --git a/web/WEB-INF/product.jsf.taglib.xml b/web/WEB-INF/product.jsf.taglib.xml index a33d611e..82a20bcb 100644 --- a/web/WEB-INF/product.jsf.taglib.xml +++ b/web/WEB-INF/product.jsf.taglib.xml @@ -40,4 +40,16 @@ along with this program. If not, see . org.mxchange.jcoreee.bean.faces.BaseFacesBean + + genericProductForm + A tag for generic product forms. + resources/tags/forms/generic_product/admin_form_generic_product_data.tpl + + targetController + A target backing bean (EL code resolving into it) extending at least BaseFacesBean where to set the data in. + true + + org.mxchange.jcoreee.bean.faces.BaseFacesBean + + diff --git a/web/WEB-INF/templates/admin/generic_product/admin_form_product_data.tpl b/web/WEB-INF/resources/tags/forms/generic_product/admin_form_generic_product_data.tpl similarity index 79% rename from web/WEB-INF/templates/admin/generic_product/admin_form_product_data.tpl rename to web/WEB-INF/resources/tags/forms/generic_product/admin_form_generic_product_data.tpl index cd134128..bab74b62 100644 --- a/web/WEB-INF/templates/admin/generic_product/admin_form_product_data.tpl +++ b/web/WEB-INF/resources/tags/forms/generic_product/admin_form_generic_product_data.tpl @@ -20,22 +20,30 @@ + + - + + + + - + + + + - + + - + + + - + + diff --git a/web/admin/generic_product/admin_generic_product_delete.xhtml b/web/admin/generic_product/admin_generic_product_delete.xhtml index c137ac6a..4fc320b1 100644 --- a/web/admin/generic_product/admin_generic_product_delete.xhtml +++ b/web/admin/generic_product/admin_generic_product_delete.xhtml @@ -10,8 +10,19 @@ - - + + + diff --git a/web/admin/generic_product/admin_generic_product_edit.xhtml b/web/admin/generic_product/admin_generic_product_edit.xhtml index 2b66f87f..4e74068e 100644 --- a/web/admin/generic_product/admin_generic_product_edit.xhtml +++ b/web/admin/generic_product/admin_generic_product_edit.xhtml @@ -2,6 +2,7 @@ - - + + + @@ -24,18 +36,22 @@ - + - - + + - - + + @@ -43,7 +59,9 @@ - + @@ -53,10 +71,9 @@ /> diff --git a/web/admin/generic_product/admin_generic_product_list.xhtml b/web/admin/generic_product/admin_generic_product_list.xhtml index 280e8ed2..f7f344a0 100644 --- a/web/admin/generic_product/admin_generic_product_list.xhtml +++ b/web/admin/generic_product/admin_generic_product_list.xhtml @@ -2,6 +2,7 @@ - + @@ -105,7 +106,13 @@ title="#{project.FILTER_BY_MULTIPLE_PRODUCT_CATEGORIES_TITLE}" > - + + @@ -145,7 +152,13 @@ title="#{msg.FILTER_BY_MULTIPLE_COMPANIES_TITLE}" > - + + @@ -157,7 +170,7 @@ - + @@ -187,7 +200,7 @@ - + @@ -260,7 +273,7 @@ - + @@ -268,7 +281,7 @@ - + - + @@ -291,10 +304,9 @@ /> diff --git a/web/admin/generic_product/admin_generic_product_show.xhtml b/web/admin/generic_product/admin_generic_product_show.xhtml index 796bc376..e0e58eb3 100644 --- a/web/admin/generic_product/admin_generic_product_show.xhtml +++ b/web/admin/generic_product/admin_generic_product_show.xhtml @@ -10,8 +10,19 @@ - - + + + diff --git a/web/admin/product_category/admin_product_category_list.xhtml b/web/admin/product_category/admin_product_category_list.xhtml index 16d4ce51..5e152295 100644 --- a/web/admin/product_category/admin_product_category_list.xhtml +++ b/web/admin/product_category/admin_product_category_list.xhtml @@ -75,7 +75,7 @@ oncomplete="PF('categoryDialog').show()" /> - + @@ -96,7 +96,13 @@ title="#{project.FILTER_BY_MULTIPLE_PRODUCT_CATEGORIES_TITLE}" > - + + @@ -140,7 +146,7 @@ - + @@ -164,7 +170,7 @@ - +