Package net.sourceforge.stripes.validation

Examples of net.sourceforge.stripes.validation.SimpleError


    /** Validates that only resources in the allowed places are asked for. */
    @ValidationMethod
    public void validate(ValidationErrors errors) {
        if (resource.startsWith("/WEB-INF") && !resource.startsWith("/WEB-INF/src")) {
            errors.add("resource",
                       new SimpleError("Naughty, naughty. We mustn't hack the URL now."));
        }
    }
View Full Code Here


    /** A divide event that validates that we're not dividing by zero. */
    @HandlesEvent("divide")
    public Resolution divide() {
        if (rhs == 0) {
            getContext().getValidationErrors().add("rhs", new SimpleError("Rhs may not be zero"));
            return getContext().getSourcePageResolution();
        }

        this.result = lhs / rhs;
        getContext().getRequest().setAttribute("integerResult", (int) this.result);
View Full Code Here

            int id = Integer.valueOf(input);
            BugManager bugManager = new BugManager();
            bug = bugManager.getBug(id);
        }
        catch (NumberFormatException e) {
            errors.add(new SimpleError("The number {0} is not a valid Bug ID", input));
        }

        return bug;
    }
View Full Code Here

            int id = Integer.valueOf(input);
            PersonManager personManager = new PersonManager();
            person = personManager.getPerson(id);
        }
        catch (NumberFormatException e) {
            errors.add(new SimpleError("The number {0} is not a valid Person ID", input));
        }

        return person;
    }
View Full Code Here

            int id = Integer.valueOf(input);
            ComponentManager componentManager = new ComponentManager();
            component = componentManager.getComponent(id);
        }
        catch (NumberFormatException e) {
            errors.add(new SimpleError("The number {0} is not a valid Component ID", input));
        }

        return component;
    }
View Full Code Here

     * are not dividing by zero.
     */
    @ValidationMethod(on="division")
    public void avoidDivideByZero(ValidationErrors errors) {
        if (this.numberTwo == 0) {
            errors.add("numberTwo", new SimpleError("Dividing by zero is not allowed."));
        }
    }
View Full Code Here

    public Category convert(String s, Class<? extends Category> aClass, Collection<ValidationError> validationErrors) {
        try {
            return categoryDao.getCategory(new Integer(s));
        catch(Exception e) {
            validationErrors.add(new SimpleError("Chybny format."));
            return null;
        }
    }
View Full Code Here

    public Tag convert(String s, Class<? extends Tag> aClass, Collection<ValidationError> validationErrors) {
        try {
            return tagsDao.getTag(new Integer(s));
        } catch (Exception e) {
            validationErrors.add(new SimpleError("Chybny format."));
            return null;
        }
    }
View Full Code Here

    @ValidationMethod(on = {"enableDisable", "delete"})
    public void validate(ValidationErrors errors) {
        user = userDao.getUser(id);
        if(user.getRoles().contains("ROLE_SUPERUSER")) {
            errors.addGlobalError(new SimpleError("Akci nem��ete s dan�m u�ivatelem prov�st."));
        }
    }
View Full Code Here

        if (newPasswordRetype == null)
            newPasswordRetype = "";

        String currentUserPassword = userDao.getUser(getCurrentUsername()).getPassword();
        if (!passwordEncoder.encodePassword(getOldPassword().trim(), applicationConfiguration.getSystemWideSalt()).equals(currentUserPassword)) {
            errors.add("oldPassword", new SimpleError("Zadali jste �patn� p�vodn� heslo"));
        }

        if (newPassword.length() < 5) {
            errors.add("newPassword", new SimpleError("Nov� heslo mus� b�t nejm�n� 5 znak� dlouh�"));
        }
        if (!newPassword.equals(newPasswordRetype)) {
            errors.add("newPasswordRetype", new SimpleError("Hesla nesouhlas�"));
        }

    }
View Full Code Here

TOP

Related Classes of net.sourceforge.stripes.validation.SimpleError

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.