Announcement

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

    FilterClause exception

    Hi,
    I'am using SGWT Pro 12.0 released July 30, 2018.
    My code with the old version worked but now I have this exception in browser console

    Code:
    Uncaught TypeError: Cannot read property 'contains' of null
        at _3.isc_FilterClause_updateOperatorDefault [as updateOperatorDefault] (ISC_DataBinding.js?plin_version=12.0p_2018-07-30:2981)
        at _3.isc_FilterClause_updateFields [as updateFields] (ISC_DataBinding.js?plin_version=12.0p_2018-07-30:2981)
        at _3.isc_FilterClause_fieldNameChanged [as fieldNameChanged] (ISC_DataBinding.js?plin_version=12.0p_2018-07-30:2977)
        at _3.isc_c_Class_invokeSuper [as invokeSuper] (ISC_Core.js?plin_version=12.0p_2018-07-30:312)
        at _3.isc_c_Class_Super [as Super] (ISC_Core.js?plin_version=12.0p_2018-07-30:304)
        at _3.fieldNameChanged (ISC_DataBinding.js?plin_version=12.0p_2018-07-30:3024)
        at _3.changed (ISC_DataBinding.js?plin_version=12.0p_2018-07-30:3002)
        at _3.isc_FormItem_handleChanged [as handleChanged] (ISC_Forms.js?plin_version=12.0p_2018-07-30:1204)
        at _3.isc_FormItem_storeValue [as storeValue] (ISC_Forms.js?plin_version=12.0p_2018-07-30:1203)
        at _3.isc_FormItem__updateValue [as $10y] (ISC_Forms.js?plin_version=12.0p_2018-07-30:1200)
        at _3.isc_SelectItem_updateValue [as updateValue] (ISC_Forms.js?plin_version=12.0p_2018-07-30:2288)
        at _3.isc_SelectItem_changeToValue [as changeToValue] (ISC_Forms.js?plin_version=12.0p_2018-07-30:2279)
        at _3.isc_SelectItem_pickValue [as pickValue] (ISC_Forms.js?plin_version=12.0p_2018-07-30:2323)
        at _3.itemClick (ISC_Forms.js?plin_version=12.0p_2018-07-30:2003)
        at _3.recordClick (ISC_Forms.js?plin_version=12.0p_2018-07-30:1996)
        at _3.isc_ListGrid_rowClick [as rowClick] (ISC_Grids.js?plin_version=12.0p_2018-07-30:1623)
        at _3.isc_c_Class_invokeSuper [as invokeSuper] (ISC_Core.js?plin_version=12.0p_2018-07-30:312)
        at _3.isc_c_Class_Super [as Super] (ISC_Core.js?plin_version=12.0p_2018-07-30:304)
        at _3.rowClick (ISC_Forms.js?plin_version=12.0p_2018-07-30:1991)
        at _3.eval [as rowClick] (eval at isc__makeFunction (ISC_Core.js?plin_version=12.0p_2018-07-30:82), <anonymous>:4:115)
        at _3.isc_GridRenderer__rowClick [as $29y] (ISC_Grids.js?plin_version=12.0p_2018-07-30:569)
        at _3.isc_c_Class_invokeSuper [as invokeSuper] (ISC_Core.js?plin_version=12.0p_2018-07-30:312)
        at _3.isc_c_Class_Super [as Super] (ISC_Core.js?plin_version=12.0p_2018-07-30:304)
        at _3.isc_GridBody__rowClick [as $29y] (ISC_Grids.js?plin_version=12.0p_2018-07-30:638)
        at _3.isc_GridRenderer_click [as click] (ISC_Grids.js?plin_version=12.0p_2018-07-30:567)
        at _3.isc_Canvas_handleClick [as handleClick] (ISC_Core.js?plin_version=12.0p_2018-07-30:3494)
        at _3.isc_c_EventHandler_bubbleEvent [as bubbleEvent] (ISC_Core.js?plin_version=12.0p_2018-07-30:2130)
        at _3.isc_c_EventHandler_handleClick [as handleClick] (ISC_Core.js?plin_version=12.0p_2018-07-30:1972)
        at _3.isc_c_EventHandler__handleMouseUp [as $k5] (ISC_Core.js?plin_version=12.0p_2018-07-30:1957)
        at _3.isc_c_EventHandler_handleMouseUp [as handleMouseUp] (ISC_Core.js?plin_version=12.0p_2018-07-30:1948)
        at _3.isc_c_EventHandler_dispatch [as dispatch] (ISC_Core.js?plin_version=12.0p_2018-07-30:2217)
        at HTMLDocument.eval (eval at isc__makeFunction (ISC_Core.js?plin_version=12.0p_2018-07-30:82), <anonymous>:3:123)
    On my DataSource (searchFieldData ) I add a custom Operator for Search. This is only for the date/datetime fields

    Code:
    OperatorId[] operatorValid = new OperatorId[] { OperatorId.EQUALS, OperatorId.NOT_EQUAL, OperatorId.LESS_THAN, OperatorId.GREATER_THAN, OperatorId.LESS_OR_EQUAL, OperatorId.GREATER_OR_EQUAL, OperatorId.NOT_BLANK, OperatorId.IS_BLANK,OperatorId.IS_NULL,OperatorId.NOT_NULL};
    searchFieldData.setTypeOperators(FieldType.DATE, operatorValid);
    searchFieldData.setTypeOperators(FieldType.DATETIME, operatorValid);
    Operator newOperator=new Operator();
    newOperator.setTitle("mese corrente");
    newOperator.setID("mese_corrente");
    newOperator.setValueType(OperatorValueType.NONE);
    searchFieldData.addSearchOperator(newOperator, new FieldType[]{FieldType.DATE,FieldType.DATETIME});
    
    
    FilterBuilder filterBuilder = new FilterBuilder();
    filterBuilder.setDataSource(searchFieldData);
    filterBuilder.setFieldOperatorCustomizer(new FieldOperatorCustomizer() {
                @Override
                public OperatorId[] getFieldOperators(String fieldName, OperatorId[] defaultOperators, FilterBuilder filterBuilder) {
                    DataSource ds = filterBuilder.getDataSource();
                    DataSourceField field = ds.getField(fieldName);                
    
                    if(field.getType().equals(FieldType.DATE) || field.getType().equals(FieldType.DATETIME)){                    
                        return defaultOperators;
                    }
                          ........ ......................
                }
            });
    I note that defaultOperators is empty and in the browse console there is the exception above!

    If I modify the code with
    Code:
    filterBuilder.setFieldOperatorCustomizer(new FieldOperatorCustomizer() {
                @Override
                public OperatorId[] getFieldOperators(String fieldName, OperatorId[] defaultOperators, FilterBuilder filterBuilder) {
                    DataSource ds = filterBuilder.getDataSource();
                    DataSourceField field = ds.getField(fieldName);                
    
                   if(field.getType().equals(FieldType.DATE) || field.getType().equals(FieldType.DATETIME)){    
                         OperatorId[] defaultOperatorsDate =  searchFieldData.getFieldOperators(fieldName);
                         return defaultOperatorsDate;
                    }
    
                   ......................
    
                }
            });
    The istruction :
    searchFieldData.getFieldOperators(fieldName);
    generates an exception..

    Can you help me?
    Thanks a lot.







    #2
    What version did you upgrade from?

    Is it possible to show a full test case? We may not be able to reproduce the problem without more information.

    Comment


      #3
      Note that, while we've added a null guard to prevent this crash, this situation shouldn't be happening and seems to indicate that you've somehow configured a field such that there would be no valid search operators, so we still need a test case and your previous version info.

      Comment


        #4
        Hi,
        With the version officially released on March 27, 2018, the custom filter worked in FieldType.DATE. I have my custom option 'mese corrente'.

        Click image for larger version

Name:	filter_date_ok.png
Views:	85
Size:	49.1 KB
ID:	254332

        With the version downloaded on 30 July 2018 the type component FieldType.DATE going in exception to no longer displays the one defined in my code ...
        Click image for larger version

Name:	filter_date_no_ok.png
Views:	74
Size:	48.0 KB
ID:	254333

        I attach a test case (SearchTest.java). I have used and modified your example 'https://www.smartclient.com/smartgwt/showcase/#grid_custom_filter_builder' .
        Run this I have the exception showed in prevoius post.

        Thank you!
        Attached Files

        Comment


          #5
          Thanks - we'll take a look and update here when we have more information.

          Comment


            #6
            This was caused by a bug where the defaultOpertators passed to your customizer could be null, and downstream code requires that it isn't.

            That's been fixed from today's builds, dated August 7 and later.

            Let us know if you still see issues.

            Comment


              #7
              Hi, thanks a lot for the solution.
              Now custom filter works but I have this warning when I change field in criteria

              Code:
              WARN:Log:Uncaught exception escaped: java.lang.ArrayStoreException
              undefined
                  at fillInStackTrace_0_g$(plinning_console-0.js@3:9372)
                  at Throwable_1_g$(plinning_console-0.js@8:9310)
                  at Exception_1_g$(plinning_console-0.js@18:9458)
                  at RuntimeException_1_g$(plinning_console-0.js@18:9499)
                  at new ArrayStoreException_1_g$(plinning_console-0.js@25:369254)
                  at setCheck_0_g$(plinning_console-0.js@17:45262)
                  at toArray_5_g$(plinning_console-0.js@5:260523)
                  at arrayOfOperatorId_0_g$(plinning_console-0.js@21:253200)
                  at <anonymous>(plinning_console-0.js@24:322240)
                  at apply_0_g$(plinning_console-0.js@28:11774)
                  at entry0_0_g$(plinning_console-0.js@16:11830)
                  at getFieldOperators(plinning_console-0.js@14:11810)
                  at isc_FilterClause_getFieldOperators(http://localhost:8888/plinning_console/sc/modules/ISC_DataBinding.js?plin_version=12.0p_2018-08-25@293:2989)
                  at isc_FilterClause__getFieldOperators(http://localhost:8888/plinning_console/sc/modules/ISC_DataBinding.js?plin_version=12.0p_2018-08-25@107:2989)
                  at isc_FilterClause_updateOperatorDefault(http://localhost:8888/plinning_console/sc/modules/ISC_DataBinding.js?plin_version=12.0p_2018-08-25@332:2981)
                  at isc_FilterClause_updateFields(http://localhost:8888/plinning_console/sc/modules/ISC_DataBinding.js?plin_version=12.0p_2018-08-25@792:2981)
                  at isc_FilterClause_fieldNameChanged(http://localhost:8888/plinning_console/sc/modules/ISC_DataBinding.js?plin_version=12.0p_2018-08-25@933:2977)
                  at isc_c_Class_invokeSuper(http://localhost:8888/plinning_console/sc/modules/ISC_Core.js?plin_version=12.0p_2018-08-25@93:313)
                  at isc_c_Class_Super(http://localhost:8888/plinning_console/sc/modules/ISC_Core.js?plin_version=12.0p_2018-08-25@170:305)
                  at fieldNameChanged(http://localhost:8888/plinning_console/sc/modules/ISC_DataBinding.js?plin_version=12.0p_2018-08-25@1085:3024)
                  at changed(http://localhost:8888/plinning_console/sc/modules/ISC_DataBinding.js?plin_version=12.0p_2018-08-25@1088:3002)
                  at isc_FormItem_handleChanged(http://localhost:8888/plinning_console/sc/modules/ISC_Forms.js?plin_version=12.0p_2018-08-25@22:1204)
                  at isc_FormItem_storeValue(http://localhost:8888/plinning_console/sc/modules/ISC_Forms.js?plin_version=12.0p_2018-08-25@23:1203)
                  at isc_FormItem__updateValue(http://localhost:8888/plinning_console/sc/modules/ISC_Forms.js?plin_version=12.0p_2018-08-25@68:1200)
                  at isc_SelectItem_updateValue(http://localhost:8888/plinning_console/sc/modules/ISC_Forms.js?plin_version=12.0p_2018-08-25@46:2294)
                  at isc_SelectItem_changeToValue(http://localhost:8888/plinning_console/sc/modules/ISC_Forms.js?plin_version=12.0p_2018-08-25@91:2285)
                  at isc_SelectItem_pickValue(http://localhost:8888/plinning_console/sc/modules/ISC_Forms.js?plin_version=12.0p_2018-08-25@6:2329)
                  at itemClick(http://localhost:8888/plinning_console/sc/modules/ISC_Forms.js?plin_version=12.0p_2018-08-25@4:2009)
                  at recordClick(http://localhost:8888/plinning_console/sc/modules/ISC_Forms.js?plin_version=12.0p_2018-08-25@141:2002)
                  at isc_ListGrid_rowClick(http://localhost:8888/plinning_console/sc/modules/ISC_Grids.js?plin_version=12.0p_2018-08-25@22:1629)
                  at isc_c_Class_invokeSuper(http://localhost:8888/plinning_console/sc/modules/ISC_Core.js?plin_version=12.0p_2018-08-25@93:313)
                  at isc_c_Class_Super(http://localhost:8888/plinning_console/sc/modules/ISC_Core.js?plin_version=12.0p_2018-08-25@170:305)
                  at rowClick(http://localhost:8888/plinning_console/sc/modules/ISC_Forms.js?plin_version=12.0p_2018-08-25@196:1997)
                  at eval(eval at isc__makeFunction (http://localhost:8888/plinning_console/sc/modules/ISC_Core.js?plin_version=12.0p_2018-08-25@122:83)
                  at isc_GridRenderer__rowClick(http://localhost:8888/plinning_console/sc/modules/ISC_Grids.js?plin_version=12.0p_2018-08-25@183:569)
                  at isc_c_Class_invokeSuper(http://localhost:8888/plinning_console/sc/modules/ISC_Core.js?plin_version=12.0p_2018-08-25@93:313)
                  at isc_c_Class_Super(http://localhost:8888/plinning_console/sc/modules/ISC_Core.js?plin_version=12.0p_2018-08-25@170:305)
                  at isc_GridBody__rowClick(http://localhost:8888/plinning_console/sc/modules/ISC_Grids.js?plin_version=12.0p_2018-08-25@76:638)
                  at isc_GridRenderer_click(http://localhost:8888/plinning_console/sc/modules/ISC_Grids.js?plin_version=12.0p_2018-08-25@167:567)
                  at isc_Canvas_handleClick(http://localhost:8888/plinning_console/sc/modules/ISC_Core.js?plin_version=12.0p_2018-08-25@400:3498)
                  at isc_c_EventHandler_bubbleEvent(http://localhost:8888/plinning_console/sc/modules/ISC_Core.js?plin_version=12.0p_2018-08-25@89:2134)
                  at isc_c_EventHandler_handleClick(http://localhost:8888/plinning_console/sc/modules/ISC_Core.js?plin_version=12.0p_2018-08-25@50:1974)
                  at isc_c_EventHandler__handleMouseUp(http://localhost:8888/plinning_console/sc/modules/ISC_Core.js?plin_version=12.0p_2018-08-25@11:1959)
                  at isc_c_EventHandler_handleMouseUp(http://localhost:8888/plinning_console/sc/modules/ISC_Core.js?plin_version=12.0p_2018-08-25@57:1950)
                  at isc_c_EventHandler_dispatch(http://localhost:8888/plinning_console/sc/modules/ISC_Core.js?plin_version=12.0p_2018-08-25@108:2221)
                  at eval(eval at isc__makeFunction (http://localhost:8888/plinning_console/sc/modules/ISC_Core.js?plin_version=12.0p_2018-08-25@122:83)

              And I note that the my code getFieldOperators is never called
              Code:
              filterBuilder.setFieldOperatorCustomizer(new FieldOperatorCustomizer() {
              
                          @Override
                          public OperatorId[] getFieldOperators(String fieldName, OperatorId[] defaultOperators, FilterBuilder filterBuilder) {
                              DataSource ds = filterBuilder.getDataSource();
                              DataSourceField field = ds.getField(fieldName);                
              
                             if(field.getType().equals(FieldType.DATE) || field.getType().equals(FieldType.DATETIME)){    
                                   OperatorId[] defaultOperatorsDate =  searchFieldData.getFieldOperators(fieldName);
                                   return defaultOperatorsDate;
                              }
              
                            field.setValidOperators(OperatorId.IS_NULL,OperatorId.NOT_NULL);
              
                              if (field.getType().equals(FieldType.INTEGER) || field.getType().equals(FieldType.FLOAT) ) {
                                  return new OperatorId[] { OperatorId.EQUALS, OperatorId.NOT_EQUAL, OperatorId.LESS_THAN, OperatorId.GREATER_THAN, OperatorId.LESS_OR_EQUAL, OperatorId.GREATER_OR_EQUAL, OperatorId.NOT_BLANK, OperatorId.IS_BLANK,OperatorId.IS_NULL,OperatorId.NOT_NULL};
                              }else if (field.getType().equals(FieldType.BOOLEAN)  ) {
                                  return new OperatorId[] { OperatorId.EQUALS, OperatorId.NOT_EQUAL, OperatorId.IS_BLANK, OperatorId.NOT_BLANK,OperatorId.IS_NULL,OperatorId.NOT_NULL };
                              }
                             return new OperatorId[] { OperatorId.ICONTAINS, OperatorId.ISTARTS_WITH, OperatorId.IENDS_WITH,
                              OperatorId.IEQUALS, OperatorId.INOT_EQUAL,
                              OperatorId.INOT_CONTAINS, OperatorId.INOT_STARTS_WITH, OperatorId.INOT_ENDS_WITH,
                              OperatorId.EQUALS, OperatorId.NOT_EQUAL, OperatorId.LESS_THAN, OperatorId.GREATER_THAN, OperatorId.LESS_OR_EQUAL, OperatorId.GREATER_OR_EQUAL, OperatorId.NOT_BLANK, OperatorId.IS_BLANK};  
                         }
                      });
              Can you help me?

              I download last SGWT Pro 12.0 released August 25, 2018.
              Thanks.

              Comment


                #8
                This issue was just fixed earlier today - it surfaced as a result of fixing the previous issue - please retest with a build dated August 28 or later

                Comment


                  #9
                  Thanks a lot!

                  Comment

                  Working...
                  X