Package org.apache.cocoon.forms.validation

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


        try {
            expressionResult = expression.evaluate(expressionContext);
        } catch (CannotYetResolveWarning w) {
            return w;
        } catch (ExpressionException e) {
            return new ValidationError("Error evaluating \"" + exprName + "\" expression on \"" +
                                       ruleName + "\" validation rule", false);
        }
       
        if (!(expressionResult instanceof Comparable)) {
            return new ValidationError("Got non-comparable result from \"" + exprName + "\" expression on \"" +
                                       ruleName + "\" validation rule", false);
        }

        return expressionResult;
    }
View Full Code Here


                }
            }
            I18nMessage message = new I18nMessage("upload.invalid-type",
                                                  new String[] {contentType},
                                                  FormsConstants.I18N_CATALOGUE);
            setValidationError(new ValidationError(message));
            return false;
        }

        // No mime type restriction
        return true;
View Full Code Here

        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

        }

        if (this.part == null) {
            if (this.definition.isRequired()) {
                I18nMessage i18nMessage = new I18nMessage("general.field-required", FormsConstants.I18N_CATALOGUE);
                setValidationError(new ValidationError(i18nMessage));
            }
        } else if (validateOversize() && validateMimeType()) {
            super.validate();
        }
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

            // Invalid widget type
            throw new IllegalArgumentException("Widget '" + widget.getRequestParameterName() + "' is not ValidationErrorAware");
        }
        boolean result = widget.getValue() != null && widget.getValue().equals(widget.getAttribute("secret"));
        if (! result) {
            ((ValidationErrorAware) widget).setValidationError(new ValidationError(VALIDATION_MESSAGE_KEY));
        }
        return result;
    }
View Full Code Here

        // rule called getValue(), so then we just return the parsed (but not VALUE_VALIDATED) value to avoid an endless loop
        if (this.valueState == VALUE_VALIDATING) {
            return this.value;
        }

        ValidationError oldError = this.validationError;

        // Parse the value
        if (this.valueState == VALUE_UNPARSED) {
            doParse();
        }
View Full Code Here

        } else {
            changed = !enteredValue.equals(newEnteredValue);
        }

        if (changed) {
            ValidationError oldError = this.validationError;

            // If we have some value-changed listeners, we must make sure the current value has been
            // parsed, to fill the event. Otherwise, we don't need to spend that extra CPU time.
            boolean hasListeners = hasValueChangedListeners() || this.getForm().hasFormHandler();
            Object oldValue = hasListeners ? getValue() : null;
View Full Code Here

        this.validationError = null;

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

        if (rows.size() > getMaxSize() || rows.size() < getMinSize()) {
            String [] boundaries = new String[2];
            boundaries[0] = String.valueOf(getMinSize());
            boundaries[1] = String.valueOf(getMaxSize());
            this.validationError = new ValidationError(new I18nMessage("repeater.cardinality", boundaries, FormsConstants.I18N_CATALOGUE));
            valid=false;
        }


        if (valid) {
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.