Re: Validation on my own

From: Martino Limido (martyma..ac.com)
Date: Tue May 03 2011 - 12:39:21 UTC

  • Next message: Kieran Kelleher: "Re: Validation on my own"

    Hi Peter,
    very easy workaround: use local variables and then set the values in the EO record.

    Bye

    Martino

    Il giorno 03/mag/2011, alle ore 14:31, Peter Müller ha scritto:

    > 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:40:18 UTC