]> git.mxchange.org Git - jcoreee.git/blobdiff - src/org/mxchange/jcoreee/validator/number/BaseLongValidator.java
Added flag allowNull to allow null ...
[jcoreee.git] / src / org / mxchange / jcoreee / validator / number / BaseLongValidator.java
index c0f737ea88e166b3c6f0df8f1ec1ecd243ef0d2a..b5475d09e10fa59b53b6d2c710c3036fb4383bd1 100644 (file)
@@ -16,6 +16,7 @@
  */
 package org.mxchange.jcoreee.validator.number;
 
+import java.text.MessageFormat;
 import javax.faces.application.FacesMessage;
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
@@ -25,7 +26,7 @@ import org.mxchange.jcoreee.validator.BaseObjectValidator;
 
 /**
  * A general number value validator.
- *
+ * <p>
  * @author Roland Haeder<roland@mxchange.org>
  */
 public abstract class BaseLongValidator extends BaseObjectValidator implements Validator {
@@ -36,12 +37,12 @@ public abstract class BaseLongValidator extends BaseObjectValidator implements V
        private static final long serialVersionUID = 25_481_878_590_589_321L;
 
        @Override
-       public void preValidate (final FacesContext context, final UIComponent component, final Object value, final String[] requiredFields) throws ValidatorException {
+       public void preValidate (final FacesContext context, final UIComponent component, final Object value, final String[] requiredFields, boolean allowNull) throws ValidatorException {
                // Trace message
                //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);
+               super.preValidate(context, component, value, requiredFields, allowNull);
 
                // Get client id and init message + key
                String clientId = component.getClientId();
@@ -58,7 +59,7 @@ public abstract class BaseLongValidator extends BaseObjectValidator implements V
                                // Compare value's type
                                if (!(value instanceof Long)) {
                                        // Generate message
-                                       requiredMessage = this.getMessageStringFromKey(String.format("ERROR_%s_IS_NOT_LONG", field.toUpperCase()));
+                                       requiredMessage = MessageFormat.format("Field {0} is not Long.", field); //NOI18N
 
                                        // Value is not right type
                                        facesMessage = new FacesMessage(FacesMessage.SEVERITY_ERROR, requiredMessage, requiredMessage); //NOI18N
@@ -71,7 +72,7 @@ public abstract class BaseLongValidator extends BaseObjectValidator implements V
                                // Is the number below zero?
                                if (num < 0) {
                                        // Generate message
-                                       requiredMessage = this.getMessageStringFromKey(String.format("ERROR_%s_IS_BELOW_ZERO", field.toUpperCase()));
+                                       requiredMessage = MessageFormat.format("Value {0} for field {1} is below zero.", num, field); //NOI18N
 
                                        // Abort processing here
                                        facesMessage = new FacesMessage(FacesMessage.SEVERITY_ERROR, requiredMessage, requiredMessage);