Announcement

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

    String length validation run on includeFrom field

    Hi,

    After migration to v10.0p_2015-11-14/PowerEdition Deployment (from v9.1p_2014-06-08/PowerEdition) I hit a bug with validations: string length validation is run on my includeFrom field, in this case DESCRIPTOR_STATUS.

    After I change value of DESCRIPTOR_ID in combo box to empty, ListGrid.getEditValues returns the following values:
    Code:
    Object { CELL_NAME: "CELL1", DESCRIPTOR_ID: null, DESCRIPTOR_NAME: "<span aria-hidden='true'>&nbsp;</span>" }
    (in 9.1 it was just "&nbsp;")

    Now, when I submit this change, SmartClient runs length validation. Log:

    Code:
    21:05:21.556 [ppr][qtp133544411-42] DEBUG com.isomorphic.rpc.RPCManager - Request #1 (DSRequest) payload: {
        criteria:{
            CELL_NAME:"BT334972"
        },
        values:{
            CELL_NAME:"BT334972",
            DESCRIPTOR_ID:null,
            DESCRIPTOR_NAME:"<span aria-hidden='true'>&nbsp;</span>"
        },
        operationConfig:{
            dataSource:"cells2gDS",
            repo:null,
            operationType:"update",
            textMatchStyle:"exact"
        },
        componentId:"siteCells2gList",
        appID:"builtinApplication",
        operation:"cells2gDS_update",
        oldValues:{
    ...
        }
    }
    ...
    21:05:21.558 [ppr][qtp133544411-42] DEBUG c.i.datasource.BasicDataSource - Looking up Spring bean 'sqlDataSource' as implementer for DataSource cells2gDS
    21:05:21.560 [ppr][qtp133544411-42] DEBUG c.i.datasource.BasicDataSource - Looking up Spring bean 'sqlDataSource' as implementer for DataSource cells2gDS
    21:05:21.562 [ppr][qtp133544411-42] DEBUG c.i.datasource.BasicDataSource - Looking up Spring bean 'sqlDataSource' as implementer for DataSource cells2gDS
    21:05:21.567 [ppr][qtp133544411-42] DEBUG c.i.datasource.BasicDataSource - [builtinApplication.cells2gDS_update] Validating 1 'cells2gDS's at path ''
    21:05:21.567 [ppr][qtp133544411-42] DEBUG c.i.datasource.BasicDataSource - [builtinApplication.cells2gDS_update] Validating a 'cells2gDS' at path ''
    [B]21:05:21.567 [ppr][qtp133544411-42] DEBUG com.isomorphic.validation.Validation - [builtinApplication.cells2gDS_update] Creating simple type validator for simple type: text
    21:05:21.567 [ppr][qtp133544411-42] DEBUG c.i.datasource.BasicDataSource - [builtinApplication.cells2gDS_update] for field: DESCRIPTOR_NAMEadding automatically generated lengthRange validator for length:20[/B]
    21:05:21.567 [ppr][qtp133544411-42] DEBUG com.isomorphic.validation.Validation - [builtinApplication.cells2gDS_update] Creating field validator for field cells2gDS.DESCRIPTOR_NAME, of simple type: text, with inline validators: [], and type validators: [isString]
    21:05:21.567 [ppr][qtp133544411-42] DEBUG com.isomorphic.validation.Validation - [builtinApplication.cells2gDS_update] Validating field:
    /cells2gDS/DESCRIPTOR_NAME as cells2gDS.DESCRIPTOR_NAME type: text
    21:05:21.568 [ppr][qtp133544411-42] DEBUG c.i.datasource.ValidationContext - [builtinApplication.cells2gDS_update] Adding validation errors at path '/cells2gDS/DESCRIPTOR_NAME/DESCRIPTOR_NAME': {errorMessage=Must be no more than 20 characters long}
    21:05:21.568 [ppr][qtp133544411-42] DEBUG com.isomorphic.validation.Validation - [builtinApplication.cells2gDS_update] Validating field:
    /cells2gDS/CELL_NAME as cells2gDS.CELL_NAME type: text
    21:05:21.569 [ppr][qtp133544411-42] DEBUG c.i.datasource.BasicDataSource - [builtinApplication.cells2gDS_update] Done validating 1 'cells2gDS's at path '': 2ms (avg 2)
    21:05:21.569 [ppr][qtp133544411-42] DEBUG com.isomorphic.datasource.DataSource - [builtinApplication.cells2gDS_update] post-validation valueSet: [
        {
            CELL_NAME:"BT334972",
            DESCRIPTOR_ID:null,
            DESCRIPTOR_NAME:"<span aria-hidden='true'>&nbsp;</span>"
        }
    ]
    21:05:21.569 [ppr][qtp133544411-42] INFO  com.isomorphic.validation.Validation - [builtinApplication.cells2gDS_update] Validation error: [
        {
            DESCRIPTOR_NAME:{
                errorMessage:"[B]Must be no more than 20 characters long[/B]"
            }
        }
    ]
    Data source:
    Code:
    <DataSource ID="cells2gDS"
                serverType="sql"
                tableName="v_cells_2g_diff"
                serverConstructor="spring:sqlDataSource"
                strictSQLFiltering="true"
                autoDeriveSchema="true"
                ignoreTextMatchStyleCaseSensitive="true">
        <fields>
            <field name="CELL_NAME" primaryKey="true" ignoreTextMatchStyle="true"/>
            <field name="DESCRIPTOR_ID" foreignKey="descriptors2gDS.DESCRIPTOR_ID" joinType="outer"
                   displayField="DESCRIPTOR_NAME" editorType="SelectItem" filterEditorType="ComboBoxItem" allowEmptyValue="true" />
    
            <field name="DESCRIPTOR_NAME" includeFrom="descriptors2gDS.DESCRIPTOR_NAME" />
        </fields>
    </DataSource>
    Is my configuration correct?

    #2
    If the field you are including has a validator declared on it in the DataSource you are including from, it's expected that that validator is carried over to the including DataSource.

    The problem here is that you somehow end up with than chunk of HTML (<span ..>) as an edit value which is submitted to the server. If you can show a test case where this seems to happen due to a framework bug, we can take a look.

    Comment


      #3
      Test case:
      1. Open http://localhost:8080/isomorphic/sys...sqlIncludeFrom (or http://www.smartclient.com/#SQLsqlIncludeFrom)
      2. Change countryId in cityIncludeFromSQL - editorType="SelectItem" allowEmptyValue="true", resulting in:
      Code:
      <DataSource
          ID="cityIncludeFromSQL"
          serverType="sql"
          tableName="city"
      >
          <fields>
              <field name="cityId"        type="sequence" hidden="true"   primaryKey="true" />
              <field name="cityName"      type="text"     title="City"    required="true" />
              <field name="continent" includeFrom="countryIncludeFromSQL.continentName"   title="Continent"   />
              <field name="countryId" type="integer"  foreignKey="countryIncludeFromSQL.countryId" displayField="countryName" title="Country" editorType="SelectItem" allowEmptyValue="true"/>
              <field includeFrom="countryIncludeFromSQL.countryName"  hidden="true"   />
          </fields>
      </DataSource>
      3. Run
      4. Change any country to empty

      DS Request will look like that:
      Code:
      {
          dataSource:"cityIncludeFromSQL",
          operationType:"update",
          componentId:"cityList",
          data:{
              cityId:5,
              countryId:null,
              countryName:"[B]<span aria-hidden='true'>&nbsp;</span>[/B]"
          },
      On another note, in my case I can prevent DESCRIPTOR_NAME from being sent at all by setting autoFetchDisplayMap to true, but I want to limit the number of requests from client. Shouldn't the update request be the same, regardless of autoFetchDisplayMap setting?
      Last edited by Crack; 25 Nov 2015, 06:12.

      Comment


        #4
        Ok, after trying to go around this I believe there are two bugs:
        1. countyName (or, in my case, DESCRIPTOR_NAME) shouldn't be sent to server or behavior should be consistent regardless of autoFetchDisplayMap setting
        2. SelectItem returns emptyDisplayValue as field value when choosing empty value

        For now I solved this by setting emptyDisplayValue to "" on all SelectItems.

        Comment


          #5
          sorry for the delayed response.

          1. we couldn't reproduce the inconsistent behavior you described, when countryName would be sent or not to the server depending on autoDetchDisplayMap setting. Could you double check that and describe use case in more detail?
          2. this is fixed now, if countryId is null, then countryName will be null as well. You may check out 10.0 nightly builds from Dec 12.

          Comment


            #6
            Sorry for late reply.

            1. I cannot reproduce it in latest nightly (10.1), so it looks like it was fixed (or I was just testing it wrong)
            2. Thanks

            Comment

            Working...
            X