Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    valueManager.validate() call returns failed responses for several dynamic forms

    After upgrade from smartgwt 3 to smartgwt 5 (current version is 5.0p.2016-06-25) we noticed strange behavior for validation from valueManager.validate(). (Browser: FF 26 version)
    I tried to reproduce the problem on the DMI Validation show case for better explanation our conditions (version 5.0p.2016-06-25).
    Here is the changes which I inserted into DMIValidationSample class and also one small change into validationDMI_orderForm.ds.xml file.
    DMIValidationSample.java validationDMI_orderForm.ds.xml
    We have several dynamic forms with the different fields from the same datasource and common valueManager.
    One of the fields from one form has serverCustom validator (in our case it is quantity), and another field from the second form is required(in our case it is instructions).
    When we fill ALL fields we click on submit button and call valueManager.validate() .
    In the dev console we see validation request which is failed. Click image for larger version

Name:	2016-06-30 15_46_31-SmartClient Developer Console.png
Views:	145
Size:	55.6 KB
ID:	238935
    But we don't see any errors on the forms, which are actually correct because forms are valid (we filled all fields correctly).Also if clear value from quantity field we will not see any error messages.
    After investigation I realized that valueManager.validate() calls inside dynamicForm.validate -> Canvas.fireServerValidation -> dataSource.validate method but only with the values from the fields belonging to this current dynamic form.That's why we don't see field instructions in the request, because it is from another form.
    We also checked smart gwt3 version for this behavior and response for validation request was successfull. (May be because there was no datasource validation inside?? )

    If to come back to our personal case in our application where we call valueManager,validate() before valueManager.save() :
    if (valuesManager.validate()) {
    DSRequest requestProperties = new DSRequest();
    requestProperties.setWillHandleError(true);
    valuesManager.saveData(callback, requestProperties);
    }
    then we can notice also that valueManager.validate() always returns true (even we serverCustom validator described in datasource return false). And it looks like that serverCustom Validator was not called at all.(Breakpoint was not touched during debugging in DMI Validator class. ).
    But this serverCustom Validator was called in the call to valuesManager.saveData(). So again some validation happened and only then we can see error message on the forms.

    Could you please explain such behavior?Why it was changed? Is it considered as a bug?(we didn't change our logic at this piece of code since smart gwt 3 version)
    Thanks in advance, Ksenia

    #2
    Originally posted by ksenia_korenkova View Post
    After upgrade from smartgwt 3 to smartgwt 5 (current version is 5.0p.2016-06-25) we noticed strange behavior for validation from valueManager.validate(). (Browser: FF 26 version)
    I tried to reproduce the problem on the DMI Validation show case for better explanation our conditions (version 5.0p.2016-06-25).
    Here is the changes which I inserted into DMIValidationSample class and also one small change into validationDMI_orderForm.ds.xml file.
    [ATTACH]n238934[/ATTACH] [ATTACH]n238936[/ATTACH]
    We have several dynamic forms with the different fields from the same datasource and common valueManager.
    One of the fields from one form has serverCustom validator (in our case it is quantity), and another field from the second form is required(in our case it is instructions).
    When we fill ALL fields we click on submit button and call valueManager.validate() .
    In the dev console we see validation request which is failed. [ATTACH=CONFIG]n238935[/ATTACH]
    But we don't see any errors on the forms, which are actually correct because forms are valid (we filled all fields correctly).Also if clear value from quantity field we will not see any error messages.
    After investigation I realized that valueManager.validate() calls inside dynamicForm.validate -> Canvas.fireServerValidation -> dataSource.validate method but only with the values from the fields belonging to this current dynamic form.That's why we don't see field instructions in the request, because it is from another form.
    We also checked smart gwt3 version for this behavior and response for validation request was successfull. (May be because there was no datasource validation inside?? )
    Everything you describe is behavior as intended. Only one server request is sent because only the first DynamicForm has a validator that must run on the server. That DynamicForm (and thus the record it sends for validation) don't contain the "instructions" field, so the "required" declaration fires on the server, but that's OK because the client filters that out, knowing that that field doesn't belong to the first DataSource.

    There is no error when you leave the "quantity" field blank because that field isn't required - it's only verified if it's sent to the server and it's not sent if it's left blank.

    The exact series of client-server messages isn't something we guarantee to remain fixed across releases, so it indeed may have changed since SGWT 3, but that's to be expected.

    Originally posted by ksenia_korenkova View Post
    If to come back to our personal case in our application where we call valueManager,validate() before valueManager.save() :
    if (valuesManager.validate()) {
    DSRequest requestProperties = new DSRequest();
    requestProperties.setWillHandleError(true);
    valuesManager.saveData(callback, requestProperties);
    }
    then we can notice also that valueManager.validate() always returns true (even we serverCustom validator described in datasource return false). And it looks like that serverCustom Validator was not called at all.(Breakpoint was not touched during debugging in DMI Validator class. ).
    But this serverCustom Validator was called in the call to valuesManager.saveData(). So again some validation happened and only then we can see error message on the forms.

    Could you please explain such behavior?Why it was changed? Is it considered as a bug?(we didn't change our logic at this piece of code since smart gwt 3 version)
    Thanks in advance, Ksenia
    The valuesManager.validate() call is only synchronous if all validation can be done on the client. Any server validation, if required, is performed asynchronously.. To deal with asynchronous server replies In the SGWT 5.0p release, you have to check each DynamicForm separately via DynamicForm.isPendingAsyncValidation(), setting up a handler with DynamicForm.addAsyncValidationReplyHandler(). In SGWT 6.0p, we've added these APIs at the ValuesManager level so it's a bit simpler.

    Comment

    Working...
    X