Package org.joget.apps.form.model

Examples of org.joget.apps.form.model.FormValidator


            element.setOptionsBinder(optionsBinder);
            FormStoreBinder storeBinder = (FormStoreBinder) FormUtil.parseBinderFromJsonObject(obj, FormBinder.FORM_STORE_BINDER);
            element.setStoreBinder(storeBinder);

            // set validator
            FormValidator validator = FormUtil.parseValidatorFromJsonObject(obj);
            if (validator != null) {
                validator.setElement(element);
                element.setValidator(validator);
            }
        }

        return element;
View Full Code Here


     * @param obj
     * @return
     * @throws Exception
     */
    public static FormValidator parseValidatorFromJsonObject(JSONObject obj) throws Exception {
        FormValidator validator = null;
        PluginManager pluginManager = (PluginManager) appContext.getBean("pluginManager");
        if (!obj.isNull(FormUtil.PROPERTY_PROPERTIES)) {
            JSONObject objProperty = obj.getJSONObject(FormUtil.PROPERTY_PROPERTIES);
            if (!objProperty.isNull(FormUtil.PROPERTY_VALIDATOR)) {
                String validatorStr = objProperty.getString(FormUtil.PROPERTY_VALIDATOR);
                JSONObject validatorObj = new JSONObject(validatorStr);

                // create validator object
                if (!validatorObj.isNull(FormUtil.PROPERTY_CLASS_NAME)) {
                    String className = validatorObj.getString(FormUtil.PROPERTY_CLASS_NAME);
                    if (className != null && className.trim().length() > 0) {
                        validator = (FormValidator) pluginManager.getPlugin(className);
                        if (validator != null) {
                            // set child properties
                            Map<String, Object> properties = FormUtil.parsePropertyFromJsonObject(validatorObj);
                            validator.setProperties(properties);
                        }
                    }
                }
            }
        }
View Full Code Here

     * @return true if all validators are successful.
     */
    public static boolean executeValidators(Element element, FormData formData) {
        boolean result = true;
        if (element.continueValidation(formData)) {
            FormValidator validator = (FormValidator) element.getValidator();
            if (validator != null) {
                String[] values = FormUtil.getElementPropertyValues(element, formData);
                result = validator.validate(element, formData, values) && result;
            }
            result = element.selfValidate(formData) && result;
           
            Collection<Element> children = element.getChildren(formData);
            if (children != null) {
View Full Code Here

     * @param formData
     * @return
     */
    public static String getElementValidatorDecoration(Element element, FormData formData) {
        String decoration = "";
        FormValidator validator = element.getValidator();
        if (validator != null) {
            decoration = validator.getElementDecoration(element, formData);
            if (decoration == null) {
                decoration = "";
            }
        }
        return decoration;
View Full Code Here

        // set properties
        JSONObject jsonProps = FormUtil.generatePropertyJsonObject(element.getProperties());
        jsonObj.put(FormUtil.PROPERTY_PROPERTIES, jsonProps);

        // set validator
        FormValidator validator = element.getValidator();
        if (validator != null) {
            JSONObject jsonValidatorProps = FormUtil.generatePropertyJsonObject(validator.getProperties());
            JSONObject jsonValidator = new JSONObject();
            jsonValidator.put(FormUtil.PROPERTY_CLASS_NAME, validator.getClassName());
            jsonValidator.put(FormUtil.PROPERTY_PROPERTIES, jsonValidatorProps);
            jsonProps.put(FormUtil.PROPERTY_VALIDATOR, jsonValidator);
        }

        // set load binder
View Full Code Here

TOP

Related Classes of org.joget.apps.form.model.FormValidator

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.