Package org.apache.cocoon.forms.util

Examples of org.apache.cocoon.forms.util.I18nMessage


        }

        if (values != null) {
            validationError = definition.getDatatype().validate(values, new ExpressionContextImpl(this));
        } else if (invalidEnteredValue != null) {
            validationError = new ValidationError(new I18nMessage("multivaluefield.conversionfailed", new String[] {invalidEnteredValue}, FormsConstants.I18N_CATALOGUE));
        }

        this.wasValid = validationError == null ? super.validate() : false;
        return this.wasValid;
    }
View Full Code Here


        if (enteredValue != null && !fieldsHaveValues()) {
            XMLizable failMessage = getAggregateFieldDefinition().getSplitFailMessage();
            if (failMessage != null) {
                validationError = new ValidationError(failMessage);
            } else {
                validationError = new ValidationError(new I18nMessage("aggregatedfield.split-failed",
                                                                      new String[] { getAggregateFieldDefinition().getSplitRegexp() },
                                                                      FormsConstants.I18N_CATALOGUE));
            }
            valueState = VALUE_DISPLAY_VALIDATION;
            this.wasValid = false;
View Full Code Here

            max = (Comparable) result;
        }
       
        if (min != null && max != null) {
            if (decimal.compareTo(min) < 0 || decimal.compareTo(max) > 0) {
                return hasFailMessage() ? getFailMessage() : new ValidationError(new I18nMessage("validation.numeric.range",
                                                                                 new String[]{min.toString(), max.toString()},
                                                                                 FormsConstants.I18N_CATALOGUE));
            }

            return null;
        } else if (min != null) {
            if (decimal.compareTo(min) < 0) {
                return hasFailMessage() ? getFailMessage() : new ValidationError(new I18nMessage("validation.numeric.min",
                                                                                 new String[]{min.toString()},
                                                                                 FormsConstants.I18N_CATALOGUE));
            }
            return null;
        } else if (max != null) {
            if (decimal.compareTo(max) > 0) {
                return hasFailMessage() ? getFailMessage() : new ValidationError(new I18nMessage("validation.numeric.max",
                                                                                 new String[]{max.toString()},
                                                                                 FormsConstants.I18N_CATALOGUE));
            }
            return null;
        }
View Full Code Here

            } else if (result instanceof CannotYetResolveWarning) {
                return null;
            }
            int length = ((BigDecimal)result).intValue();
            if (string.length() != length) {
                return hasFailMessage() ? getFailMessage() : new ValidationError(new I18nMessage("validation.string.exact-length", new String[] {String.valueOf(length)}, FormsConstants.I18N_CATALOGUE));
            }
            return null;
        } else if (minExpr != null && maxExpr != null) {
            Object result = evaluateNumeric(minExpr, expressionContext, "min", "length");
            if (result instanceof ValidationError) {
                return (ValidationError)result;
            } else if (result instanceof CannotYetResolveWarning) {
                return null;
            }
            int minLength = ((BigDecimal)result).intValue();

            result = evaluateNumeric(maxExpr, expressionContext, "max", "length");
            if (result instanceof ValidationError) {
                return (ValidationError)result;
            } else if (result instanceof CannotYetResolveWarning) {
                return null;
            }
            int maxLength = ((BigDecimal)result).intValue();

            if (string.length() < minLength || string.length() > maxLength) {
                return hasFailMessage() ? getFailMessage() : new ValidationError(new I18nMessage("validation.string.range-length", new String[] {String.valueOf(minLength), String.valueOf(maxLength)}, FormsConstants.I18N_CATALOGUE));
            }
            return null;
        } else if (minExpr != null) {
            Object result = evaluateNumeric(minExpr, expressionContext, "min", "length");
            if (result instanceof ValidationError) {
                return (ValidationError)result;
            } else if (result instanceof CannotYetResolveWarning) {
                return null;
            }
            int length = ((BigDecimal)result).intValue();
            if (string.length() < length) {
                return hasFailMessage() ? getFailMessage() : new ValidationError(new I18nMessage("validation.string.min-length", new String[] {String.valueOf(length)}, FormsConstants.I18N_CATALOGUE));
            }
            return null;
        } else if (maxExpr != null) {
            Object result = evaluateNumeric(maxExpr, expressionContext, "max", "length");
            if (result instanceof ValidationError) {
                return (ValidationError)result;
            } else if (result instanceof CannotYetResolveWarning) {
                return null;
            }
            int length = ((BigDecimal)result).intValue();
            if (string.length() > length) {
                return hasFailMessage() ? getFailMessage() : new ValidationError(new I18nMessage("validation.string.max-length", new String[] {String.valueOf(length)}, FormsConstants.I18N_CATALOGUE));
            }
            return null;
        }
        return null;
    }
View Full Code Here

            } else if (result instanceof CannotYetResolveWarning) {
                return null;
            }
            int length = ((BigDecimal)result).intValue();
            if (array.length != length) {
                return hasFailMessage() ? getFailMessage() : new ValidationError(new I18nMessage("validation.array.exact-valuecount", new String[] {String.valueOf(length)}, FormsConstants.I18N_CATALOGUE));
            }
            return null;
        } else if (minExpr != null && maxExpr != null) {
            Object result = evaluateNumeric(minExpr, expressionContext, "min", "value-count");
            if (result instanceof ValidationError) {
                return (ValidationError)result;
            } else if (result instanceof CannotYetResolveWarning) {
                return null;
            }
            int minLength = ((BigDecimal)result).intValue();

            result = evaluateNumeric(maxExpr, expressionContext, "max", "value-count");
            if (result instanceof ValidationError) {
                return (ValidationError)result;
            } else if (result instanceof CannotYetResolveWarning) {
                return null;
            }
            int maxLength = ((BigDecimal)result).intValue();

            if (array.length < minLength || array.length > maxLength) {
                return hasFailMessage() ? getFailMessage() : new ValidationError(new I18nMessage("validation.array.range-valuecount", new String[] {String.valueOf(minLength), String.valueOf(maxLength)}, FormsConstants.I18N_CATALOGUE));
            }
            return null;
        } else if (minExpr != null) {
            Object result = evaluateNumeric(minExpr, expressionContext, "min", "value-count");
            if (result instanceof ValidationError) {
                return (ValidationError)result;
            } else if (result instanceof CannotYetResolveWarning) {
                return null;
            }
            int length = ((BigDecimal)result).intValue();
            if (array.length < length) {
                return hasFailMessage() ? getFailMessage() : new ValidationError(new I18nMessage("validation.array.min-valuecount", new String[] {String.valueOf(length)}, FormsConstants.I18N_CATALOGUE));
            }
            return null;
        } else if (maxExpr != null) {
            Object result = evaluateNumeric(maxExpr, expressionContext, "max", "value-count");
            if (result instanceof ValidationError) {
                return (ValidationError)result;
            } else if (result instanceof CannotYetResolveWarning) {
                return null;
            }
            int length = ((BigDecimal)result).intValue();
            if (array.length > length) {
                return hasFailMessage() ? getFailMessage() : new ValidationError(new I18nMessage("validation.array.max-valuecount", new String[] {String.valueOf(length)}, FormsConstants.I18N_CATALOGUE));
            }
            return null;
        }
        return null;
    }
View Full Code Here

      String string = (String)value;
     
      if(matchesRegExp(string))
         return null;  
      else
        return hasFailMessage() ? getFailMessage() : new ValidationError(new I18nMessage("validation.string.regexp", new String[] {regexp}, FormsConstants.I18N_CATALOGUE));
    }
View Full Code Here

            } else {
                sum += currentDigit;
            }
        }
        if(!((sum % 10) == 0))
            return hasFailMessage() ? getFailMessage() : new ValidationError(new I18nMessage("validation.mod10", FormsConstants.I18N_CATALOGUE));
        else
            return null;
    }
View Full Code Here

        String email = (String)value;

        if (isEmail(email))
            return null;
        else
            return hasFailMessage() ? getFailMessage() : new ValidationError(new I18nMessage("validation.string.invalidemail", FormsConstants.I18N_CATALOGUE));
    }
View Full Code Here

            while(tok.hasMoreTokens()) {
                if (tok.nextToken().equals(contentType)) {
                    return true;
                }
            }
            I18nMessage message = new I18nMessage("upload.invalid-type",
                                                  new String[] {contentType},
                                                  FormsConstants.I18N_CATALOGUE);
            setValidationError(new ValidationError(message));
            return false;
        }
View Full Code Here

        // Set a validation error indicating the sizes in kbytes (rounded)
        RejectedPart rjp = (RejectedPart)this.part;
        int size = (rjp.getContentLength() + 512) / 1024;
        int maxSize = (rjp.getMaxContentLength() + 512) / 1024;
        String[] i18nParams = new String[] { String.valueOf(size), String.valueOf(maxSize) };
        I18nMessage i18nMessage = new I18nMessage("upload.rejected", i18nParams, FormsConstants.I18N_CATALOGUE);
        setValidationError(new ValidationError(i18nMessage));
        return false;
    }
View Full Code Here

TOP

Related Classes of org.apache.cocoon.forms.util.I18nMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.