Package org.apache.cocoon.forms.validation

Examples of org.apache.cocoon.forms.validation.ValidationError


        if (!getCombinedState().isValidatingValues())
            return true;

        if (this.part == null) {
            if (this.uploadDefinition.isRequired()) {
                this.validationError = new ValidationError(new I18nMessage("general.field-required", Constants.I18N_CATALOGUE));
            }
        } else {
            String mimeTypes = this.uploadDefinition.getMimeTypes();
            if (mimeTypes != null) {
                StringTokenizer tok = new StringTokenizer(this.uploadDefinition.getMimeTypes(), ", ");
                this.validationError = new ValidationError(new I18nMessage("upload.invalid-type", Constants.I18N_CATALOGUE));
                String contentType = this.part.getMimeType();
                while (tok.hasMoreTokens()) {
                    if (tok.nextToken().equals(contentType)) {
                        this.validationError = null;
                    }
View Full Code Here


        this.valueState = VALUE_VALIDATING;

        try {
            if (this.value == null && getFieldDefinition().isRequired()) {
                // Field is required
                this.validationError = new ValidationError(new I18nMessage("general.field-required", Constants.I18N_CATALOGUE));
            } else {
                if (super.validate() && value != null) {
                    // New-style validators were successful. Check the old-style ones.
                    this.validationError = getDatatype().validate(value, new ExpressionContextImpl(this));
                }
View Full Code Here

     * <p>Note: this is not done as a constructor because
     * it would conflict with the constructor which takes
     * an Object as argument.
     */
    public static ConversionResult create(String datatypeName) {
        ValidationError validationError = new ValidationError(new I18nMessage(
            "datatype.conversion-failed",
            new String[] {"datatype." + datatypeName},
            new boolean[] { true },
            Constants.I18N_CATALOGUE
        ));
View Full Code Here

            return true;

        if (values != null)
            validationError = definition.getDatatype().validate(values, new ExpressionContextImpl(this));
        else
            validationError = new ValidationError(new I18nMessage("multivaluefield.conversionfailed", Constants.I18N_CATALOGUE));

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

            return true;

        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() },
                                                                      Constants.I18N_CATALOGUE));
            }
            valueState = VALUE_DISPLAY_VALIDATION;
            return false;
View Full Code Here

            case EVENT_ELEMENT:
                return bufferHandler;

            case EVENT_END_ELEMENT:
                if (widget instanceof ValidationErrorAware) {
                    ValidationError error = ((ValidationErrorAware)widget).getValidationError();
                    if (error != null) {
                        out.startElement(Constants.INSTANCE_NS, VALIDATION_ERROR, Constants.INSTANCE_PREFIX_COLON + VALIDATION_ERROR, XMLUtils.EMPTY_ATTRIBUTES);
                        error.generateSaxFragment(stylingHandler);
                        out.endElement(Constants.INSTANCE_NS, VALIDATION_ERROR, Constants.INSTANCE_PREFIX_COLON + VALIDATION_ERROR);
                    }
                }
                widget = null;
                out.bufferFini();
View Full Code Here

            // No value. Consider it as correct (required="true" will set an error if present)
            return true;
           
        } else {
            // Non-null value: perform validation
            ValidationError error = this.rule.validate(value, new ExpressionContextImpl(widget));
            if (error != null) {
                // Validation failed
                ((ValidationErrorAware)widget).setValidationError(error);
                return false;
            } else {
View Full Code Here

                parms = new String[len];
                for (int i = 0; i < len; i++) {
                    parms[i] = Context.toString(getProperty(obj, i));
                }
            }
            ValidationError validationError = null;
            if (message != null) {
                if (parms != null && parms.length > 0) {
                    validationError =
                        new ValidationError(Context.toString(message), parms);
                } else {
                    validationError =
                        new ValidationError(Context.toString(message), parms != null);
                }
            }
            ((ValidationErrorAware)delegate).setValidationError(validationError);
            formWidget.notifyValidationErrorListener(this, validationError);
        }
View Full Code Here

    public ValidationError validate(Object value, ExpressionContext expressionContext) {
        Iterator validationRulesIt = validationRules.iterator();
        while (validationRulesIt.hasNext()) {
            ValidationRule validationRule = (ValidationRule)validationRulesIt.next();
            ValidationError result = validationRule.validate(value, expressionContext);
            if (result != null)
                return result;
        }
        return null;
    }
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()},
                                                                                 Constants.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()},
                                                                                 Constants.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()},
                                                                                 Constants.I18N_CATALOGUE));
            }
            return null;
        }
View Full Code Here

TOP

Related Classes of org.apache.cocoon.forms.validation.ValidationError

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.