Announcement

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

    Unexpected fetch for ID from ListGrid-filterRow on filter (Bug?)

    Hi Isomorphic,

    please see this modified buildInDs-sample form today's nightly (v9.1p_2014-07-08):

    BuiltInDS.java:
    Code:
    package com.smartgwt.sample.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.core.KeyIdentifier;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.types.OperatorId;
    import com.smartgwt.client.util.PageKeyHandler;
    import com.smartgwt.client.util.Page;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.form.fields.TextItem;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridField;
    
    public class BuiltInDS implements EntryPoint {
    	private ListGrid boundList;
    	public void onModuleLoad() {
    		KeyIdentifier debugKey = new KeyIdentifier();
    		debugKey.setCtrlKey(true);
    		debugKey.setKeyName("D");
    
    		Page.registerKey(debugKey, new PageKeyHandler() {
    			public void execute(String keyName) {
    				SC.showConsole();
    			}
    		});
    
    		DataSource ds = DataSource.get("animals");
    		boundList = new ListGrid();
    		boundList.setDataSource(ds);
    		boundList.setHeight(500);
    		boundList.setWidth(500);
    		boundList.setShowFilterEditor(true);
    		boundList.setAutoFetchData(false);
    
    		ListGridField scientificName = new ListGridField("scientificName");
    		ListGridField commonName = new ListGridField("commonName");
    		ListGridField lifeSpan = new ListGridField("lifeSpan") {
    			{
    				setSortByDisplayField(true);
    				setFilterEditorProperties(new TextItem());
    				setFilterOperator(OperatorId.ICONTAINS);
    			}
    		};
    
    		boundList.setFields(scientificName, commonName, lifeSpan);
    		boundList.draw();
    		boundList.fetchData();
    	}
    }
    animals.ds.xml:
    Code:
    <DataSource ID="animals" serverType="sql" tableName="animals" testFileName="animals.data.xml">
    	<fields>
    		<field name="commonName" title="Animal" type="text" />
    		<field name="scientificName" title="Scientific Name" type="text" primaryKey="true" required="true" />
    [B]		<field name="lifeSpan" foreignKey="employees.EmployeeId" title="Life Span" type="integer" displayField="testfield" />
    		<field name="testfield" includeFrom="employees.Name" hidden="true" />
    [/B]		<field name="status" title="Endangered Status" type="text">
    			<valueMap>
    				<value>Threatened</value>
    				<value>Endangered</value>
    				<value>Not Endangered</value>
    				<value>Not currently listed</value>
    				<value>May become threatened</value>
    				<value>Protected</value>
    			</valueMap>
    		</field>
    		<field name="diet" title="Diet" type="text" />
    		<field name="information" title="Interesting Facts" type="text" length="1000" />
    		<field name="picture" title="Picture" type="image" detail="true" imageURLPrefix="/isomorphic/system/reference/inlineExamples/tiles/images/" />
    	</fields>
    </DataSource>
    I also changed some animal's lifeSpan in animals.data.xml in order to get Join-matches to the employees.EmployeeId (for some reason I can't see any data in the ListGrid, even though the join is correct and matching data is there, but that is not what this is about).

    With this configuration I'd expect employees.Name data (strings) in the 3rd column and that is what's happening in my application (Oracle based).

    If you now try to filter on the 3rd column and e.g. enter "Iso" in the field and hit enter, I get the following request / log data:

    RPC-Tab of Developer Console window:
    Code:
    {
        dataSource:"employees", 
        operationType:"fetch", 
        componentId:"isc_ListGrid_0filterEditor_body", 
        data:{
            EmployeeId:"Iso"
        }, 
        textMatchStyle:"exact", 
        callback:{
            target:[TextItem ID:isc_TextItem_3 name:lifeSpan], 
            methodName:"fetchMissingValueReply"
        }, 
        showPrompt:false, 
        oldValues:{
            EmployeeId:"Iso"
        }, 
        requestId:"employees$6271", 
        internalClientContext:{
            dataValue:"Iso", 
            filterLocally:{
            }
        }, 
        fallbackToEval:false, 
        componentContext:"lifeSpan", 
        lastClientEventThreadCode:"IFCS2", 
        bypassCache:true
    }
    Server log:
    Code:
    === 2014-07-09 21:10:36,053 [4-33] INFO  Download - Returning 304: Not modified on conditional get of: C:\Users\salekt\workspace\lib\smartgwtee-4.1p\samples\built-in-ds\war\builtinds\sc\skins\Enterprise\images\ListGrid\sort_descending.png
    === 2014-07-09 21:10:38,866 [4-46] INFO  RequestContext - URL: '/builtinds/sc/IDACall', User-Agent: 'Mozilla/5.0 (Windows NT 6.2; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0': Moz (Gecko) with Accept-Encoding header
    === 2014-07-09 21:10:38,867 [4-46] DEBUG IDACall - Header Name:Value pair: Cookie:isc_cState=ready; JSESSIONID=d5zeh4h5wlfj5mv7qur11xop; GLog=%7B%0D%20%20%20%20left%3A1161%2C%20%0D%20%20%20%20top%3A0%2C%20%0D%20%20%20%20width%3A638%2C%20%0D%20%20%20%20height%3A479%2C%20%0D%20%20%20%20priorityDefaults%3A%7B%0D%20%20%20%20%20%20%20%20Log%3A4%0D%20%20%20%20%7D%2C%20%0D%20%20%20%20defaultPriority%3A3%2C%20%0D%20%20%20%20trackRPC%3Atrue%0D%7D
    === 2014-07-09 21:10:38,867 [4-46] DEBUG IDACall - Header Name:Value pair: DNT:1
    === 2014-07-09 21:10:38,867 [4-46] DEBUG IDACall - Header Name:Value pair: Host:127.0.0.1:8888
    === 2014-07-09 21:10:38,867 [4-46] DEBUG IDACall - Header Name:Value pair: Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    === 2014-07-09 21:10:38,867 [4-46] DEBUG IDACall - Header Name:Value pair: Content-Length:978
    === 2014-07-09 21:10:38,867 [4-46] DEBUG IDACall - Header Name:Value pair: Content-Type:application/x-www-form-urlencoded; charset=UTF-8
    === 2014-07-09 21:10:38,867 [4-46] DEBUG IDACall - Header Name:Value pair: Accept-Language:de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
    === 2014-07-09 21:10:38,867 [4-46] DEBUG IDACall - Header Name:Value pair: Pragma:no-cache
    === 2014-07-09 21:10:38,867 [4-46] DEBUG IDACall - Header Name:Value pair: Connection:keep-alive
    === 2014-07-09 21:10:38,867 [4-46] DEBUG IDACall - Header Name:Value pair: Referer:http://127.0.0.1:8888/BuiltInDS.html?gwt.codesvr=127.0.0.1:9997
    === 2014-07-09 21:10:38,868 [4-46] DEBUG IDACall - Header Name:Value pair: User-Agent:Mozilla/5.0 (Windows NT 6.2; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0
    === 2014-07-09 21:10:38,868 [4-46] DEBUG IDACall - Header Name:Value pair: Cache-Control:no-cache
    === 2014-07-09 21:10:38,868 [4-46] DEBUG IDACall - Header Name:Value pair: Accept-Encoding:gzip, deflate
    === 2014-07-09 21:10:38,868 [4-46] DEBUG IDACall - session exists: d5zeh4h5wlfj5mv7qur11xop
    === 2014-07-09 21:10:38,868 [4-46] DEBUG IDACall - remote user: null
    === 2014-07-09 21:10:38,880 [4-46] DEBUG XML - Parsed XML from (in memory stream): 7ms
    === 2014-07-09 21:10:38,880 [4-46] DEBUG ISCKeyedObjectPool - Borrowing object for 'transaction'
    === 2014-07-09 21:10:38,881 [4-46] DEBUG ISCKeyedObjectPool - Borrowing object for 'Object'
    === 2014-07-09 21:10:38,882 [4-46] DEBUG ISCKeyedObjectPool - Borrowing object for 'List'
    === 2014-07-09 21:10:38,883 [4-46] DEBUG ISCKeyedObjectPool - Borrowing object for 'elem'
    === 2014-07-09 21:10:38,884 [4-46] DEBUG RPCManager - Processing 1 requests.
    === 2014-07-09 21:10:38,884 [4-46] DEBUG ISCKeyedObjectPool - Borrowing object for 'employees'
    === 2014-07-09 21:10:38,885 [4-46] DEBUG DSRequest - Caching instance 19 of DS employees from DSRequest.getDataSource()
    === 2014-07-09 21:10:38,886 [4-46] DEBUG RPCManager - Request #1 (DSRequest) payload: {
        criteria:{
            EmployeeId:"Iso"
        },
        operationConfig:{
            dataSource:"employees",
            operationType:"fetch",
            textMatchStyle:"exact"
        },
        componentId:"isc_ListGrid_0filterEditor_body",
        appID:"builtinApplication",
        operation:"employees_fetch",
        oldValues:{
            EmployeeId:"Iso"
        }
    }
    === 2014-07-09 21:10:38,886 [4-46] INFO  IDACall - Performing 1 operation(s)
    === 2014-07-09 21:10:38,886 [4-46] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null
    === 2014-07-09 21:10:38,887 [4-46] DEBUG DeclarativeSecurity - DataSource employees is not in the pre-checked list, processing...
    === 2014-07-09 21:10:38,887 [4-46] DEBUG AppBase - [builtinApplication.employees_fetch] No userTypes defined, allowing anyone access to all operations for this application
    === 2014-07-09 21:10:38,888 [4-46] DEBUG AppBase - [builtinApplication.employees_fetch] No public zero-argument method named '_employees_fetch' found, performing generic datasource operation
    === 2014-07-09 21:10:38,889 [4-46] INFO  SQLDataSource - [builtinApplication.employees_fetch] Performing fetch operation with
    	criteria: {EmployeeId:"Iso"}	values: {EmployeeId:"Iso"}
    === 2014-07-09 21:10:38,892 [4-46] WARN  SQLWhereClause - [builtinApplication.employees_fetch] Got non-numeric value 'Iso' for numeric column 'EmployeeId', creating literal false expression: java.lang.NumberFormatException: For input string: "Iso"
    === 2014-07-09 21:10:38,893 [4-46] INFO  SQLDataSource - [builtinApplication.employees_fetch] derived query: SELECT $defaultSelectClause FROM $defaultTableClause WHERE $defaultWhereClause
    === 2014-07-09 21:10:38,894 [4-46] INFO  SQLDataSource - [builtinApplication.employees_fetch] 19: Executing SQL query on 'HSQLDB': SELECT employeeTable.Email, employeeTable.EmployeeId, employeeTable.EmployeeStatus, employeeTable.EmployeeType, employeeTable.Gender, employeeTable.Job, employeeTable.MaritalStatus, employeeTable.Name, employeeTable.OrgUnit, employeeTable.ReportsTo, employeeTable.Salary, employeeTable.userOrder FROM employeeTable WHERE ('0'='1')
    === 2014-07-09 21:10:38,895 [4-46] DEBUG PoolableSQLConnectionFactory - [builtinApplication.employees_fetch] DriverManager fetching connection for HSQLDB via jdbc url jdbc:hsqldb:hsql://localhost/isomorphic
    === 2014-07-09 21:10:38,896 [4-46] DEBUG PoolableSQLConnectionFactory - [builtinApplication.employees_fetch] Passing JDBC URL only to getConnection
    === 2014-07-09 21:10:38,898 [4-47] INFO  RequestContext - URL: '/builtinds/sc/skins/Enterprise/images/DynamicForm/checkbox_sprite.png', User-Agent: 'Mozilla/5.0 (Windows NT 6.2; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0': Moz (Gecko) with Accept-Encoding header
    === 2014-07-09 21:10:38,898 [4-33] INFO  RequestContext - URL: '/builtinds/sc/system/reference/skin/images/server_client_exchange.png', User-Agent: 'Mozilla/5.0 (Windows NT 6.2; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0': Moz (Gecko) with Accept-Encoding header
    === 2014-07-09 21:10:38,900 [4-47] INFO  Download - done streaming: C:/Users/salekt/workspace/lib/smartgwtee-4.1p/samples/built-in-ds/war/builtinds/sc/skins/Enterprise/images/DynamicForm/checkbox_sprite.png
    === 2014-07-09 21:10:38,903 [4-33] INFO  Download - done streaming: C:/Users/salekt/workspace/lib/smartgwtee-4.1p/samples/built-in-ds/war/builtinds/sc/system/reference/skin/images/server_client_exchange.png
    === 2014-07-09 21:10:38,999 [4-46] DEBUG PoolableSQLConnectionFactory - [builtinApplication.employees_fetch] makeObject() created an unpooled Connection '762161803'
    === 2014-07-09 21:10:38,999 [4-46] DEBUG SQLConnectionManager - [builtinApplication.employees_fetch] Borrowed connection '762161803'
    === 2014-07-09 21:10:38,999 [4-46] DEBUG SQLDriver - [builtinApplication.employees_fetch] About to execute SQL query in 'HSQLDB' using connection '762161803'
    === 2014-07-09 21:10:38,999 [4-46] INFO  SQLDriver - [builtinApplication.employees_fetch] Executing SQL query on 'HSQLDB': SELECT employeeTable.Email, employeeTable.EmployeeId, employeeTable.EmployeeStatus, employeeTable.EmployeeType, employeeTable.Gender, employeeTable.Job, employeeTable.MaritalStatus, employeeTable.Name, employeeTable.OrgUnit, employeeTable.ReportsTo, employeeTable.Salary, employeeTable.userOrder FROM employeeTable WHERE ('0'='1')
    === 2014-07-09 21:10:39,003 [4-46] INFO  DSResponse - [builtinApplication.employees_fetch] DSResponse: List with 0 items
    === 2014-07-09 21:10:39,004 [4-46] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8
    === 2014-07-09 21:10:39,004 [4-46] DEBUG RPCManager - non-DMI response, dropExtraFields: false
    === 2014-07-09 21:10:39,006 [4-46] DEBUG SQLDriver - Freeing SQLDriver dbConnection 762161803
    === 2014-07-09 21:10:39,006 [4-46] DEBUG SQLConnectionManager - About to close JDBCConnection with hashcode "762161803"
    === 2014-07-09 21:10:39,007 [4-46] INFO  Compression - /builtinds/sc/IDACall: 188 -> 152 bytes
    Besides this, the filter field is also displaying "loading..." for a short amount of time.

    I'd expect to
    • Get no request to employees at all (and no "loading...")
    • If there has to be a request, it should go to employees.Name (because that is the includeFrom-source from the displayField) and therefore the framework should expect a string (see "Got non-numeric value 'Iso' for numeric column 'EmployeeId', creating literal false expression" in the log)


    Could you please tell me if this is a bug (possible in my opinion) or a misuse (or missing use) of the APIs?

    I'd like to achieve that the search is a text-only search to the display field. No lookup-request should be issued from the filterField. The filtering in the ListGrid should be ICONTAINS for this field.

    Thank you & Best regards,
    Blama

    #2
    Hi Isomorphic,

    could you already look into this and can tell me if this is a bug or expected behaviour?

    Thanks,
    Blama

    Comment


      #3
      We're taking a look. We'll follow up when we have more information for you.

      Regards
      Isomorphic Software

      Comment


        #4
        This is happening because the filter row 'lifeSpan' field is somehow acquiring an optionDataSource. We're not yet certain why this is - it seems to be specific to SmartGWT (ie, the same thing doesn't happen in an equivalent SmartClient program). We continue to investigate.

        In the meantime, an easy workaround that will give the behavior you desire is to inhibit fetchMissingValues on that field:

        Code:
        setFilterEditorProperties(new TextItem() {
            {
                setFetchMissingValues(false);
            }
        });

        Comment


          #5
          We got to the bottom of this and a fix has been put in on the SmartClient 10.0 / SmartGWT 5.0 branch. However, because there exists a clean and easy workaround (see our previous post), we do not intend to apply this fix to the 9.1 / 4.1 branch.

          Regards,
          Isomorphic Support

          Comment


            #6
            Hi Isomorphic,

            the workaround works for me in the sample and in my code. The unwanted fetch to the wrong field is gone and the filter still works as expected.

            I'll remove the workaround in my code once I switch to 5.0p.

            Thank you,
            Blama

            Comment


              #7
              Hi Isomorphic,

              after switching to 5.0p I retested this. The behaviour is still the same for me (using v10.0p_2015-04-03).

              See the request data and the attached screenshot:
              Code:
              {
                  dataSource:"employees", 
                  operationType:"fetch", 
                  componentId:"isc_ListGrid_0filterEditor_body", 
                  data:{
                      EmployeeId:"Iso"
                  }, 
                  textMatchStyle:"exact", 
                  callback:{
                      target:[TextItem ID:isc_TextItem_3 name:lifeSpan], 
                      methodName:"fetchMissingValueReply"
                  }, 
                  showPrompt:false, 
                  oldValues:{
                      EmployeeId:"Iso"
                  }, 
                  requestId:"employees$6271", 
                  internalClientContext:{
                      newValue:"Iso", 
                      filterLocally:{
                      }, 
                      targetField:"EmployeeId", 
                      fetchingMissingValues:{
                      }
                  }, 
                  fallbackToEval:false, 
                  componentContext:"lifeSpan", 
                  lastClientEventThreadCode:"IFCS5", 
                  bypassCache:true
              }
              I'm using the exact sample from above.

              Best regards,
              Blama
              Attached Files

              Comment


                #8
                Hi Isomorphic,

                could you verify in the meantime that your fix worked as intended for you?

                Best regards
                Blama

                Comment


                  #9
                  Hi Blama
                  We realize we haven't been keeping you updated on this.

                  The current status is this: This is under internal investigation - the issue is persisting for us in 10.0 and has raised some design questions which we are discussing internally.
                  For now, keep using the workaround and we'll follow up here when we have more information for you.

                  Regards
                  Isomorphic Software

                  Comment


                    #10
                    Hi Blama
                    This issue is deeper than it might appear on the surface.

                    By specifying a foreignKey value for the field, and setting up a displayField attribute, the test case sets up a situation where the editor for the field will automatically pick up an optionDataSource (the foreignKey dataSource) use it as a server-side valueMap from valueField to displayField.

                    This would be appropriate for some editor types - for example a SelectItem, where your options would indeed be expected to be derived from the related dataSource, but leads to the unexpected behavior you're seeing.

                    The actual behavior is a result of this - if the user enters an unrecognized value, it is ambiguous whether they have entered a display value (in which case a fetch should occur against the DataSource displayField to attempt to pick up the related record and the "valueField" value).
                    If they have not, the entered value must be considered a raw data value rather than a display value. In this case it might be appropriate to fetch against the dataSource, passing the user entered value in as the "valueField" criterion so the item can show the associated display value.

                    Now - in your usage, clearly this is not what you need. The user enters a freeform value which should be used directly in the criteria applied to the grid and there should be no need for these fetches to attempt to find the associated optionDataSource record.

                    Anyway - after some consideration we have come to the conclusion that this "server side valueMap" pattern is very unlikely to be the intended usage for freeform text fields as it leads to this situation where the correct behavior is ambiguous, and so we have modified the "fetchMissingValues" behavior to avoid these fetches unless the developer explicitly sets "alwaysFetchMissingValues" to true.

                    These changes have been made in 5.1 only, and we do not intend to backport, both because there is an easy workaround to the problem you encountered, and because this is a (minor) backwards compatibility issue which we would not want to introduce into an existing branch.

                    Regards
                    Isomorphic Software

                    Comment


                      #11
                      Hi Isomorphic,

                      thanks for updating and explaining. I have the workaround still in place and will revisit after changing to 5.1.

                      Best regards
                      Blama

                      Comment


                        #12
                        Hi Isomorphic,

                        I just retested with v10.1p_2016-06-03 and the fetch in question is gone now.
                        I'll remove the workaround now in my code.

                        Thank you & Best regards
                        Blama

                        Comment

                        Working...
                        X