]> git.mxchange.org Git - jfinancials-war.git/blobdiff - src/java/org/mxchange/jfinancials/validator/product_category/FinancialsProductCategoryValidator.java
Product-only:
[jfinancials-war.git] / src / java / org / mxchange / jfinancials / validator / product_category / FinancialsProductCategoryValidator.java
index 3c86937e143a8685d8e550fd5f88debd697cf615..307fbadb400e948d02beea70c65ae1a9def442ea 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017, 2018 Free Software Foundation
+ * Copyright (C) 2017 - 2022 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
@@ -33,7 +33,7 @@ import org.mxchange.jfinancials.beans.product_category.list.FinancialsCategoryLi
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-@FacesValidator(value = "ProductCategoryValidator")
+@FacesValidator (value = "ProductCategoryValidator")
 public class FinancialsProductCategoryValidator extends BaseStringValidator {
 
        /**
@@ -46,6 +46,28 @@ public class FinancialsProductCategoryValidator extends BaseStringValidator {
         */
        private static final long serialVersionUID = 1_086_256_763_716_450L;
 
+       /**
+        * Whether bypass duplicate i18n key check
+        */
+       private Boolean bypassDuplicateI18nKey;
+
+       /**
+        * Default constructor
+        */
+       public FinancialsProductCategoryValidator () {
+               // Set allowEmpty to FALSE by default
+               this.bypassDuplicateI18nKey = Boolean.FALSE;
+       }
+
+       /**
+        * Setter for bypassDuplicateI18nKey flag
+        * <p>
+        * @param bypassDuplicateI18nKey Whether to bypass i18n key duplicate-check
+        */
+       public void setBypassDuplicateI18nKey (final Boolean bypassDuplicateI18nKey) {
+               this.bypassDuplicateI18nKey = bypassDuplicateI18nKey;
+       }
+
        @Override
        public void validate (final FacesContext context, final UIComponent component, final Object categoryI18nKey) throws ValidatorException {
                // The required field
@@ -61,7 +83,7 @@ public class FinancialsProductCategoryValidator extends BaseStringValidator {
                }
 
                // Check, if the name has already been used
-               if (CATEGORY_LIST_CONTROLLER.isCategoryI18nKeyAdded((String) categoryI18nKey)) {
+               if (!this.bypassDuplicateI18nKey && CATEGORY_LIST_CONTROLLER.isCategoryI18nKeyAdded((String) categoryI18nKey)) {
                        // Create message
                        final String message = MessageFormat.format("I18n key {0} is already used. Please type an other.", categoryI18nKey);