Hi,

I ran into a problem. I have an action class with a couple of fields, for
example:

       @Validate(required = true, minvalue = 5, on = {
               "doRegister", "doValidate" })
       private String login;

I also have a couple of custom validation methods:

       @ValidationMethod(when = ValidationState.ALWAYS, on = { "doRegister",
               "doValidate" })
       public void validateLogin(ValidationErrors errors) {
           // check if login is already taken
       }


doRegister is a normal method which is called on form submit.
doValidate is called via Ajax to give users instant feedback about entered
values. It returns a JSON-formatted text

I send an ajax request like this:

//called onchange
       $.ajax({
           type: 'POST',
           url: '/customer/registration',
           data: 'doValidate=validate&field=login&login=' +
$('#login').val(),
           dataType: 'json',
           success: function(json) {
               if (json.status == 'ok') {
                   // show fancy green mark
               } else {
                   // show red cross with error message
               }
           }
       });

So, as you can see when doValidate is called not all fields are filled in.
I wanted to use

       handleValidationErrors

   from ValidationErrorHandler interface to check if doValidate is called,
and if that's the case I could filter only errors for current field.

Unfortunately it doesn't work that way. Instead for some reason only
custom validation methods are called and errors collection is empty. It
stays empty and because of that handleValidationErrors isn't called
either. Resulting behavior is strange to say the least

I wonder what I have done wrong and how to force validation checks on
fields?

Thanks in advance and sorry for long code.

Regards,
Andrey

-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to