Announcement

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

    Validation passes when ds is used in ListGrid but fails when ds is used in servlet

    Hi Isomorphic. I have the following ds descriptor (excerpt shown for brevity):
    Code:
    <field name="buffer_size" required="true">
        <title><fmt:message key="bufferbank_bufferSize"/></title>
        <validators>
    [B]       <validator type="serverCustom">
                <serverCondition>
                    <![CDATA[$value >= $editedRecord.minimum_buffer_size]]>
                </serverCondition>  
                <errorMessage><fmt:message key="bufferbank_bufferSizeInvalid"/></errorMessage>
            </validator>[/B]
        </validators>
    </field>
    
    <field name="minimum_buffer_size" required="true">
        <title><fmt:message key="bufferbank_minimumBufferSize"/></title>
    </field>    
    
    <field name="minimum_replenishment" required="true">
        <title><fmt:message key="bufferbank_minimumReplenishment"/></title>
        <validators>
    [B]       <validator type="serverCustom">
                <serverCondition>
                    <![CDATA[($value % $editedRecord.packaging_unit) == 0]]>
                </serverCondition>
                <errorMessage><fmt:message key="bufferbank_minimumReplenishmentInvalidMultiplier"/></errorMessage>
            </validator>[/B]
        </validators>
    </field>    
    
    <field name="packaging_unit" required="true">
        <title><fmt:message key="bufferbank_packagingUnit"/></title>
    </field>
    When I bind the DS to a ListGrid, create/edit a record, and feed a value of 5 for all these fields, the validation passes and the record is saved correctly. But when I use this DS in a server side request, the record is not created because the two validations highlighted above fail. If I remove these two validations from the ds descriptor, records can be correctly added/edited both using the ListGrid or the servlet initiated DSRequest.

    The errors I get in SmartGWT's server log are:
    INFO Validation - [builtinApplication.null] Validation error: [
    {
    minimum_replenishment:{
    errorMessage:"Value must be multiple of Packaging Unit."
    },
    buffer_size:{
    errorMessage:"Value must be zero or positive decimal and equal or greater than Minimum Buffer Size."
    }
    The servlet mentioned above is used to process the contents of a file received through an upload operation (declared in a separate DS descriptor and referenced via an operationBinding), which after receiving the uploaded file, parses its contents, and finally tries to create/update records from another DS (the one partially shown above) executing individual server DSRequests for each record found on the file. I already checked the Map<String, Object> record content to make sure that dsRequest.setValues(record) is receiving the correct values (ruling out a parsing error on my part).

    Any ideas why this may be happening? At first I thought that maybe $editedRecord wasn't available in the servlet's DSRequest context, but in the ds descriptor I have several other fields that use it for their validations without any problems...

    I wan't able to isolate this to a simple test case, but if you need more information, please let me know....

    SmartGWT 6.0p 2016-04-12, Chrome 50.0.2661.87 m, Windows 10.

    #2
    Without being able to see any code or the rest of the log (please don't post partial logs), the error messages suggest that your DSRequest just doesn't have the values you think it does. We would need a test case to look further.

    Comment


      #3
      As a note for people visiting this thread, Isomorphic was right. The values sent in the DSRequests were not correct (the data types, specifically). After following their advice here, I was able to get my requests to work as expected.

      Thanks

      Comment


        #4
        Thanks for confirming that, it's always good to have a thread like this wrapped up in case someone else comes across it.

        Comment

        Working...
        X