Announcement

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

    serverCustom validator not called for update to NULL

    Hi Isomorphic,

    please see this BuiltInDS based testcase (using v10.1p_2016-03-07):

    Change to employees.ds.xml:
    Code:
    <field name="Job"             title="Title"           type="text"     length="128">
        <validators>
            <validator type="serverCustom">
                <serverObject lookupStyle="new" className="com.smartgwt.sample.server.listener.FalseValidator" />
                <errorMessage>$errorMessage</errorMessage>
            </validator>
        </validators>        
    </field>
    [B][/B]

    FalseValidator.java:
    Code:
    package com.smartgwt.sample.server.listener;
    
    import java.util.Map;
    
    import com.isomorphic.datasource.DataSource;
    import com.isomorphic.datasource.Validator;
    import com.isomorphic.log.Logger;
    
    public class FalseValidator {
    
        public boolean condition(Object value, Validator validator, String fieldName, @SuppressWarnings("rawtypes") Map record, DataSource ds)
                throws Exception {
            Logger log = new Logger("com.isomorphic." + FalseValidator.class.getName());
            log.info("Called for field \"" + fieldName + "\", value \"" + (value == null ? "NULL" : value.toString()) + "\"");
            validator.addErrorMessageVariable("errorMessage", "FalseValidator");
            return false;
        }
    }
    Open standard BuiltInDS sample and try to edit employees.Job (title="Title"). This will call validation for every change, except if you try to delete the value.
    IMHO also setting to null should trigger validation, as the serverObject could determine the outcome on other fields/conditions as well.

    I read this post of yours in an older discussion, but this was about calling all validators for every change. Here the very field where on which the validator is defined changes.

    Best regards
    Blama

    #2
    Apologies for the delay here - this is fixed for builds dated March 15 and later.

    Comment


      #3
      Hi Isomorphic,

      I think your change (now using v10.1p_2016-03-17) also made isUnique-validators fire for setToNull as well.
      This is no problem for fields with required="true", but a problem for fields with required="false".
      See this log experct from my application:
      Code:
      === 2016-03-18 17:29:03,395 [c-11] INFO  SQLDriver - [builtinApplication.null] Executing SQL query on 'Oracle' using connection '2086342691': SELECT V_LEAD_CURRENT.LEAD_ID, V_LEAD_CURRENT.MD_SOURCEUID FROM V_LEAD_CURRENT WHERE (V_LEAD_CURRENT.MD_SOURCEUID [B]IS NULL[/B])
      === 2016-03-18 17:29:03,396 [c-11] INFO  DSResponse - DSResponse: [B]List with 80 items[/B]
      === 2016-03-18 17:29:03,404 [c-11] DEBUG ValidationContext - Adding validation errors at path '/V_LEAD_CURRENT/MD_SOURCEUID/MD_SOURCEUID': {errorMessage=myError!}
      === 2016-03-18 17:29:03,404 [c-11] INFO  Validation - Validation error: [
          {
              MD_SOURCEUID:{
                  errorMessage:"myError!"
              }
          }
      ]
      See the "List with 80 items". Before (v10.1p_2016-03-07), it was obviously possible to have this field empty and not-validated.
      I have no problem with the now-default behavior if I can change something to get the old behavior back (for isUnique-validators only, for "normal" user-defined serverCustom this is wanted), but I assume that you will see this as a bug as it affects in-production applications in an unexpected way.

      Best regards
      Blama

      Comment


        #4
        Hi Isomorphic,

        can you reproduce?
        Thinking about it I think the fix is the following:
        • Leave the triggering of the serverSide validation as it now is (also for NULL-values)
        • Change the isUnique-validator code, so that the validation is not executed for NULL-values
        Best regards
        Blama

        Comment


          #5
          Yes, that's the change we've made - you can try it out in tomorrow's builds.

          Comment


            #6
            Hi Isomorphic,

            thanks, it is working now (v10.1p_2016-03-22).

            Best regards
            Blama

            Comment

            Working...
            X