Announcement

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

    Validation Called Multiple Times by ValuesManager

    SmartClient Version: v9.0p_2013-09-14/PowerEdition Deployment (built 2013-09-14)

    There has been prior discussion in this forum around server-side validators being called multiple times and the reasoning behind this (for example: http://forums.smartclient.com/showthread.php?t=15764&page=2).

    However, we found today a difference in behavior between a DynamicForm and ValuesManager that we cannot explain and were hoping you could help.

    The scenario is essentially quite simple: we have a data source which contains several fields that have one or more server-side validators on them. If we edit the datasource on a DynamicForm and then perform form.submitData(), we see a single "add" RPC request in the console.

    If instead we edit the datasource via a ValuesManager and perform vm.submitData() we see as many "validate" RPC requests as there are fields with server-side validators on them, followed by an "add" request. So, if we have four fields with server-side validators on them we see four corresponding "validate" requests. These "validate" requests have "validationMode":"full" and so all our server-side validations (some of which are quite expensive) are executed multiple times.

    Can you explain why there is a difference in how validations are performed for a DynamicForm vs. ValuesManager (why does the former not make any explicit validation requests, and why does the latter make multiple), and is there any way that we can avoid this behavior?

    Thanks,
    Gary O'Donnell

    #2
    I found another old post on this topic where it seems the conclusion was that this behavior was actually desirable and would continue, but that the multiple requests to validate would be put into a queue to reduce the network traffic. This is indeed what we now see. If 4 separate fields in the ds each have server side validators then the queue has 4 "full" validate requests which result in each of the 4 validators being called 4 times.

    Having the number of calls to DMI validators grow exponentially with their use on each additional field renders them unusable for all but the simplest cases. The proposed solution, to cache results in the servletRequest, seems overly complicated. Since we would need to do this on every one of our DMI validators it would have to be encapsulated in an easily repeatable pattern and would have to also be able to handle the case when the DSRequest is not running as part of a servlet request.

    Also, this same behavior is found on standard Isomorphic validators like hasRelatedRecord and isUnique. When these are used on multiple fields in a datasource and a ValuesManager is used to perform the save they are called multiple times which leads to a performance issue.

    To date we have avoided using server side validators because of this and instead coded the checks in a serverConstructor class as part of an overridden executeAdd or executeUpdate request. But we would like to be able to use the validation framework for these so we can get all of the benefits of being able to declare them in the ds.xml.

    If the multiple calls are not needed for DynamicForm error handling why are they needed for ValuesManager handling?

    Comment


      #3
      Any advice on this? If the multiple validations by ValuesManager is not a bug that will be fixed we will design around it, but if it is a bug we would very much like to use the framework validators as they were designed.

      Comment


        #4
        Might be related to http://forums.smartclient.com/showthread.php?t=27648 as well, as I'm also using a DynamicForm with a ValuesManager.

        Comment


          #5
          Jay, couple of questions:

          1. Are you using an explicit vm.validate() or vm.saveData()?
          2. Do you receive one server validation request per form within the vm or one request per field? I see the former so I want to confirm.

          Comment


            #6
            1. Just using vm.saveData()
            2. One DSRequest to "validate" per field that has a server-side validator. All are sent together in one queue, followed by a separate DSRequest to "add".

            In our simple test there is only one DynamicForm in the ValuesManager. If we use the DynamicForm without a ValuesManager we see only the one DSRequest to "add". If we add the ValuesManager we see the queue of "validate" requests followed by the "add".

            Comment


              #7
              A fixed has been applied which prevents the separate server validation step when calling vm.saveData(). This functionality matches that of the DynamicForm alone.

              Available in both 9.0 and 9.1d tomorrow (Oct 10).

              Comment


                #8
                Thanks! But can we please have is applied to the release we're using.

                SmartClient Version: v8.3p_2013-09-26/PowerEdition Deployment (built 2013-09-26)

                Comment


                  #9
                  These changes have been applied to 8.3 as well and will be available in the next nightly build (Oct 11 or later).

                  Comment

                  Working...
                  X