]> git.mxchange.org Git - jcore-utils.git/blobdiff - src/org/mxchange/jcoreee/validator/string/BaseStringValidator.java
BaseEeSystem is now centralized and serializable
[jcore-utils.git] / src / org / mxchange / jcoreee / validator / string / BaseStringValidator.java
index 83dc8a6ccd8ae163c62e0365b725fdee70699c45..d64f5b53d3ede8d5ed0a793007d7c7da95fccbc3 100644 (file)
  */
 package org.mxchange.jcoreee.validator.string;
 
-import java.text.MessageFormat;
-import java.util.Arrays;
 import javax.faces.application.FacesMessage;
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 import javax.faces.validator.ValidatorException;
-import org.mxchange.jcoree.BaseEeSystem;
 import org.mxchange.jcoreee.validator.BaseObjectValidator;
 
 /**
  * A general string validation class. You normally want to inherit from this
  * class for many form fields, e.g. surname, street name, city name and such.
  *
- * @author Roland Haeder
+ * @author Roland Haeder<roland@mxchange.org>
  */
 public abstract class BaseStringValidator extends BaseObjectValidator {
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 15_484_578_781_760_287L;
 
        @Override
        protected void preValidate (final FacesContext context, final UIComponent component, final Object value, final String[] requiredFields) throws ValidatorException {
                // Trace message
-               this.getLogger().logTrace(MessageFormat.format("context={0},component={1},value={2},fields={3} - CALLED!", context, component, value, Arrays.toString(requiredFields))); //NOI18N
+               //this.getLogger().logTrace(MessageFormat.format("preValidate: context={0},component={1},value={2},fields={3} - CALLED!", context, component, value, Arrays.toString(requiredFields))); //NOI18N
 
                // Pre-validate (e.g. on null)
                super.preValidate(context, component, value, requiredFields);
@@ -49,16 +50,16 @@ public abstract class BaseStringValidator extends BaseObjectValidator {
                // So far all fine, no check if the field is fine
                for (final String field : requiredFields) {
                        // Debug message
-                       this.getLogger().logDebug(MessageFormat.format("field={0},clientId={1}", field, clientId)); //NOI18N
+                       //this.getLogger().logDebug(MessageFormat.format("preValidate: field={0},clientId={1}", field, clientId)); //NOI18N
 
                        // Is it the same?
                        if (clientId.endsWith(field)) {
                                // Compare value's type
                                if (!(value instanceof String)) {
                                        // Value is empty
-                                       errKey = String.format("error.%s.is_not_string", field); //NOI18N
+                                       errKey = String.format("ERROR_%s_IS_NOT_STRING", field.toUpperCase()); //NOI18N
 
-                                       facesMessage = new FacesMessage(BaseEeSystem.getMessageStringFromKey(errKey));
+                                       facesMessage = new FacesMessage(getMessageStringFromKey(errKey));
                                }
 
                                // Cast to string
@@ -67,22 +68,21 @@ public abstract class BaseStringValidator extends BaseObjectValidator {
                                // Is it empty?
                                if (str.isEmpty()) {
                                        // Value is empty
-                                       errKey = String.format("error.%s.is_empty", field); //NOI18N
+                                       errKey = String.format("ERROR_%s_IS_EMPTY", field.toUpperCase()); //NOI18N
 
-                                       facesMessage = new FacesMessage(BaseEeSystem.getMessageStringFromKey(errKey));
+                                       facesMessage = new FacesMessage(getMessageStringFromKey(errKey));
                                }
                        }
                }
 
                // Debug message
-               this.getLogger().logDebug(MessageFormat.format("facesMessage={0}", facesMessage)); //NOI18N
-
+               //this.getLogger().logDebug(MessageFormat.format("preValidate: facesMessage={0}", facesMessage)); //NOI18N
                // Is it not null?
                if (null != facesMessage) {
                        throw new ValidatorException(facesMessage);
                }
 
                // Trace message
-               this.getLogger().logTrace("EXIT!"); //NOI18N
+               //this.getLogger().logTrace("preValidate: EXIT!"); //NOI18N
        }
 }