import java.math.BigDecimal;
import java.text.MessageFormat;
+import java.util.Objects;
import javax.ejb.EJB;
import javax.enterprise.event.Event;
import javax.enterprise.inject.Any;
import javax.faces.FacesException;
+import javax.faces.application.FacesMessage;
import javax.faces.view.ViewScoped;
import javax.faces.view.facelets.FaceletException;
import javax.inject.Inject;
*/
private String productCurrencyCode;
+ /**
+ * Product's FSC number
+ */
+ private String productFscNumber;
+
/**
* Product's gross price
*/
// Is product i18n key already used?
if (this.productListController.isProductI18nKeyAdded(this.getProductI18nKey())) {
// Then throw exception
- throw new FacesException(MessageFormat.format("Product i18n key {0} already added.", this.getProductI18nKey()));
+ throw new FacesException(MessageFormat.format("Product i18n key {0} already added.", this.getProductI18nKey())); //NOI18N
}
// Create current product instance
this.setProductBarCodeNumber(this.getCurrentProduct().getProductBarCodeNumber());
this.setProductCategory(this.getCurrentProduct().getProductCategory());
this.setProductCurrencyCode(this.getCurrentProduct().getProductCurrencyCode());
+ this.setProductFscNumber(this.getCurrentProduct().getProductFscNumber());
this.setProductGrossPrice(this.getCurrentProduct().getProductGrossPrice());
this.setProductI18nKey(this.getCurrentProduct().getProductI18nKey());
this.setProductId(this.getCurrentProduct().getProductId());
this.productCurrencyCode = productCurrencyCode;
}
+ /**
+ * Getter for product's FSC number
+ * <p>
+ * @return Product's FSC number
+ */
+ public String getProductFscNumber () {
+ return this.productFscNumber;
+ }
+
+ /**
+ * Setter for product's FSC number
+ * <p>
+ * @param productFscNumber Product's FSC number
+ */
+ public void setProductFscNumber (final String productFscNumber) {
+ this.productFscNumber = productFscNumber;
+ }
+
/**
* Getter for product's gross price
* <p>
/**
* Updates given product data from request to database
* <p>
+ * @return Redirection outcome
+ * <p>
* @throws FaceletException If something unexpected happened
*/
- public void updateProduct () throws FaceletException {
+ public String updateProduct () throws FaceletException {
// Get new product instance
final Product newProduct = this.createProductInstance();
throw new NullPointerException("newProduct is null"); //NOI18N
} else if (newProduct.getProductId() == null) {
// Throw NPE again
- throw new NullPointerException("newProduct.productId is null"); //NOI18N //NOI18N
+ throw new NullPointerException("newProduct.productId is null"); //NOI18N
} else if (newProduct.getProductId() < 1) {
// Invalid id
throw new IllegalStateException(MessageFormat.format("newProduct.productId={0} is invalid", newProduct.getProductId())); //NOI18N
}
+ // Has the product changed?
+ if (Objects.equals(newProduct, this.getCurrentProduct())) {
+ // Is the same product data, output message
+ this.showFacesMessage("admin-form-edit-generic-product:productI18nKey", "ADMIN_GENERIC_PRODUCT_NOT_UPDATED", FacesMessage.SEVERITY_WARN); //NOI18N
+ return ""; //NOI18N
+ }
+
// Init productr
final Product updatedProduct;
// Clear bean
this.clear();
+
+ // Return to admin-list view
+ return "admin_list_generic_products"; //NOI18N
}
/**
this.setProductAvailability(Boolean.FALSE);
this.setProductBarCodeNumber(null);
this.setProductCategory(null);
+ this.setProductFscNumber(null);
this.setProductGrossPrice(null);
this.setProductI18nKey(null);
this.setProductId(null);
// Set all optional fields
newProduct.setProductAgeGroup(this.getProductAgeGroup());
newProduct.setProductBarCodeNumber(this.getProductBarCodeNumber());
+ newProduct.setProductFscNumber(this.getProductFscNumber());
+ newProduct.setProductId(this.getProductId());
newProduct.setProductManufacturer(this.getProductManufacturer());
- newProduct.setProductNumber(this.getProductNumber());
newProduct.setProductNetPrice(this.getProductNetPrice());
+ newProduct.setProductNumber(this.getProductNumber());
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;
}
<?xml version="1.0" encoding="UTF-8" ?>
-<!--
-@TODO: title="#{product.ADMIN_GENERIC_PRODUCT_DATA_LEGEND_TITLE}"
--->
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:product="http://mxchange.org/jsf/jproduct/widgets"
xmlns:p="http://primefaces.org/ui"
>
- <p:fieldset legend="#{product.ADMIN_GENERIC_PRODUCT_DATA_LEGEND}">
+ <p:fieldset
+ legend="#{product.ADMIN_GENERIC_PRODUCT_DATA_LEGEND}"
+ title="#{product.ADMIN_GENERIC_PRODUCT_DATA_LEGEND_TITLE}"
+ >
<p:panelGrid
layout="grid"
columns="2"
<f:converter converterId="ProductCategoryConverter" />
- <f:selectItem itemValue="#{null}" itemLabel="#{msg.PLEASE_SELECT}" noSelectionOption="true" itemDisabled="true" />
+ <f:selectItem
+ itemValue="#{null}"
+ itemLabel="#{msg.PLEASE_SELECT}"
+ noSelectionOption="true"
+ itemDisabled="true"
+ />
<f:selectItems
value="#{categoryListController.allCategories}"
title="#{product.ADMIN_ENTER_GENERIC_PRODUCT_NUMBER_TITLE}"
/>
+ <p:outputLabel for="productFscNumber" value="#{product.ADMIN_ENTER_GENERIC_PRODUCT_FSC_NUMBER}" />
+ <p:inputText
+ id="productFscNumber"
+ value="#{adminGenericProductActionController.productFscNumber}"
+ size="7"
+ maxlength="7"
+ title="#{product.ADMIN_ENTER_GENERIC_PRODUCT_FSC_NUMBER_TITLE}"
+ validatorMessage="#{product.ERROR_PRODUCT_FSC_NUMBER_NOT_VALID}"
+ >
+ <f:validateRegex pattern="C[0-9]{6}" />
+ </p:inputText>
+
<p:outputLabel for="productBarCodeNumber" value="#{product.ADMIN_ENTER_GENERIC_PRODUCT_BARCODE_NUMBER}" />
<p:inputText
id="productBarCodeNumber"