Package com.volantis.mcs.protocols.forms.validation

Examples of com.volantis.mcs.protocols.forms.validation.TextInputFormat


    }

    protected void writeJavaScriptValidation(XFTextInputAttributes attribute,
                                             StringBuffer sb) {
       
        TextInputFormat pattern = getTextInputFormat(attribute);
       
        if (pattern != null) {
           
            String caption = getTextFromReference (attribute.getCaption (),
                                                TextEncoding.PLAIN);
            String errorMsg = getTextFromReference (attribute.getErrmsg (),
                                                 TextEncoding.PLAIN);
            if(errorMsg == null) {
                // if no error message has been provided then we
                // need to generate a sensible message
                errorMsg = "Invalid input for " +
                    ((caption != null)?caption:" a form field");
            }

            // We generate the JavaScript to perform the validation
            // If the attribute.emptryOK is true then we must test if
            // the form field is not empty and if it fails the regex
            // and only then generate the error message
            sb.append("if(!(new RegEx(\"" + pattern + "\",")
                .append("form." + attribute.getName() + ".value).match())");
           
            if(pattern.isEmptyOk()) {
                sb.append(" && (form." + attribute.getName() +".value!='')");
            }
            sb.append(") {\n errMsg += \"\\n" + errorMsg + "\";")
                .append("}\n");
        }
View Full Code Here


            Element element,
            XFTextInputAttributes attributes) {

        // Get the validation format and parse it to make sure that it is
        // valid.
        TextInputFormat inputFormat = getTextInputFormat(attributes);

        // If it is valid then add appropriate attributes.
        if (inputFormat != null) {
            String format = inputFormat.getFormat();
            if (format != null) {
                ValidationHelper helper = getValidationHelper();
                element.setAttribute("format",
                        helper.createTextInputFormat(format));
            }
            boolean emptyOk = inputFormat.isEmptyOk();
            if (emptyOk) {
                element.setAttribute("emptyok", "true");
            }
        }
    }
View Full Code Here

                    "Unknown " +
                            StylePropertyDetails.MCS_INPUT_FORMAT.getName() +
                            " value " + value);
        }

        TextInputFormat result;
        if (format == null) {
            result = null;
        } else {
            result = parser.parseFormat(attributes.getName(), format);
        }
View Full Code Here

    }

    public void writeJavaScriptValidation(
            XFTextInputAttributes attribute,
            StringBuffer sb) {
        TextInputFormat format = getTextInputFormat2(attribute);
        if (format != null) {
            String pattern = format.getFormat();
            pattern = extractPattern(pattern);

            String caption = getPlainText(attribute.getCaption());
            String errorMsg = getPlainText(attribute.getErrmsg());
            if (errorMsg == null) {
                // if no error message has been provided then we
                // need to generate a sensible message
                errorMsg = "Invalid input for " +
                        ((caption != null) ? caption : " a form field");
            }

            // We generate the JavaScript to perform the validation
            // If the attribute.emptryOK is true then we must test if
            // the form field is not empty and if it fails the regex
            // and only then generate the error message
            sb.append("if(!(new RegEx(\"").append(pattern).append("\",")
                    .append("form.")
                    .append(attribute.getName()).append(".value).match())");
            if (format.isEmptyOk()) {
                sb.append(" && (form.").append(attribute.getName())
                        .append(".value!='')");
            }
            sb.append(") {\n errMsg += \"\\n").append(errorMsg).append("\";")
                    .append("}\n");
View Full Code Here

TOP

Related Classes of com.volantis.mcs.protocols.forms.validation.TextInputFormat

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.