Package com.sparc.knappsack.forms

Examples of com.sparc.knappsack.forms.DomainRegionForm


        Domain domain = domainService.get(domainId);

        if (domain != null) {

            if (!model.containsAttribute("domainRegionForm")) {
                DomainRegionForm domainRegionForm = new DomainRegionForm();
                domainRegionForm.setDomainId(domainId);

                model.addAttribute("domainRegionForm", domainRegionForm);
            }

            model.addAttribute("domainId", domainId);
View Full Code Here


        return DomainRegionForm.class.isAssignableFrom(clazz);
    }

    @Override
    public void validate(Object target, Errors errors) {
        DomainRegionForm form = (DomainRegionForm) target;

        boolean isEdit = form.getId() != null && form.getId() > 0;

        if (!ValidationUtils.doesBindingErrorExist(errors, NAME_FIELD) && !StringUtils.hasText(form.getName())) {
            errors.rejectValue(NAME_FIELD, "domainRegionValidator.name.empty");
        }

        boolean domainRegionNameExists = domainService.doesDomainContainRegionWithName(form.getDomainId(), form.getName());
        if (isEdit && domainRegionNameExists) {
            Region region = regionService.get(form.getId());
            if (!region.getName().equals(form.getName())) {
                errors.rejectValue(NAME_FIELD, "domainRegionValidator.name.exists");
            }
        } else if (!ValidationUtils.doesFieldErrorExist(errors, NAME_FIELD) && domainRegionNameExists) {
            errors.rejectValue(NAME_FIELD, "domainRegionValidator.name.exists");
        }

        if (!ValidationUtils.doesBindingErrorExist(errors, EMAILS_FIELD)) {
            for (String email : form.getEmails()) {
                if (!ValidationUtils.doesRegexMatch(email, emailPattern)) {
                    errors.rejectValue(NAME_FIELD, "domainRegionValidator.emails.invalid");
                    break;
                }
            }
View Full Code Here

TOP

Related Classes of com.sparc.knappsack.forms.DomainRegionForm

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.