Validation on my own

From: Peter Müller (peter.mueller193..mx.net)
Date: Tue May 03 2011 - 12:31:21 UTC

  • Next message: Martino Limido: "Re: Validation on my own"

    Hello WO-Community,
    i've a coding-problem because WO does a job for me, I want to do on my own.

    I've a modelclass called "User" with a view fields:
    id, firstname, lastname, email, ...

    id is primary key, firstname, lastname and a view others are "required" fields.

    On my component I have a Form to set this fields. The "save"-Button is linked to my method:

    public WOComponent save() {
                    alertMessage=null;
                    if(selectedUser.lastname()==null) {
                            alertMessage="Lastname of user must be set!";
                            return null;
                    }
                    if(selectedUser.firstname()==null) {
                            alertMessage="Firstname of user must be set!";
                            return null;
                    }
                    if(selectedUser.username()==null) {
                            alertMessage="Username of user must be set!";
                            return null;
                    }
                    if(selectedUser.password()==null || selectedUser.password().length()<5) {
                            alertMessage="Password of user must be set and must contain at least 5 signs.";
                            return null;
                    }
                    session.defaultEditingContext().saveChanges();
                    selectedUser = null;
                    return null;
    }

    As you can see, I want to do the validation for the fields on my own (because I want to make a "nice" message to the user, and later also multilingual).

    But now the problem: If I click "save" on my component, first the form will be set, and WO validates, if all required fields are set. If not, it will print a message in console and "reset" the fields. My validation will be ignored.

    Have I any chance to validate "required" fields on my own, and ignore WO's validation?

    Thank you very much,
    All the best from germany
    Peter M.

    -- 
    Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
    belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de
    



    This archive was generated by hypermail 2.0.0 : Tue May 03 2011 - 12:32:15 UTC