]> git.mxchange.org Git - jcore-utils.git/blobdiff - src/org/mxchange/jcoreee/validator/bool/BaseBooleanValidator.java
Let's get rid of this class. It was maybe a good idea, but it required a lot work...
[jcore-utils.git] / src / org / mxchange / jcoreee / validator / bool / BaseBooleanValidator.java
index b67b5e79b562300888deeee0ce74623da22ee90f..122d0a026261e82a1f5c005ceb285e1effd4949c 100644 (file)
@@ -17,7 +17,6 @@
 package org.mxchange.jcoreee.validator.bool;
 
 import java.text.MessageFormat;
-import java.util.Arrays;
 import javax.faces.application.FacesMessage;
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIInput;
@@ -29,16 +28,21 @@ import org.mxchange.jcoreee.validator.BaseObjectValidator;
 
 /**
  * A general boolean value validator.
- *
+ * <p>
  * @author BalusC
- * @author Roland Haeder
+ * @author Roland Haeder<roland@mxchange.org>
  */
 public abstract class BaseBooleanValidator extends BaseObjectValidator implements Validator {
 
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 42_378_178_715_910_689L;
+
        @Override
        public void preValidate (final FacesContext context, final UIComponent component, final Object value, final String[] requiredFields) throws ValidatorException {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("context={0},component={1},value={2},requiredFields={3} - CALLED!", context, component, value, Arrays.toString(requiredFields))); //NOI18N
+               //this.getLogger().logTrace(MessageFormat.format("preValidate: context={0},component={1},value={2},requiredFields={3} - CALLED!", context, component, value, Arrays.toString(requiredFields))); //NOI18N
 
                // Pre-validate
                super.preValidate(context, component, value, requiredFields);
@@ -46,18 +50,22 @@ public abstract class BaseBooleanValidator extends BaseObjectValidator implement
                // Get client id and init message + key
                String clientId = component.getClientId();
                FacesMessage facesMessage = null;
+               String requiredMessage;
 
                // So far all fine, no check if the field is fine
                for (final String field : requiredFields) {
                        // Debug message
-                       this.getLogger().debug(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 Boolean)) {
+                                       // Generate message
+                                       requiredMessage = MessageFormat.format("Field {0} is not Boolean.", field); //NOI18N
+
                                        // Value is not right type
-                                       facesMessage = new FacesMessage(this.getMessageStringFromKey(String.format("error.%s.is_not_boolean", field))); //NOI18N
+                                       facesMessage = new FacesMessage(FacesMessage.SEVERITY_ERROR, requiredMessage, requiredMessage); //NOI18N
                                        break;
                                }
 
@@ -67,7 +75,7 @@ public abstract class BaseBooleanValidator extends BaseObjectValidator implement
                                // Is it false?
                                if (bool.equals(Boolean.FALSE)) {
                                        // Default message
-                                       String requiredMessage = ((UIInput) component).getRequiredMessage();
+                                       requiredMessage = ((UIInput) component).getRequiredMessage();
 
                                        if (null == requiredMessage) {
                                                Object label = component.getAttributes().get("label"); //NOI18N