/*
- * 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
* <p>
* @author Roland Häder<roland@mxchange.org>
*/
-@FacesValidator(value = "ProductCategoryValidator")
+@FacesValidator (value = "ProductCategoryValidator")
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
}
// 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);