Announcement

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

    Fetching two different selectItems

    I have two different selectItems which fetch data from the same datasource, but something is not working:

    Code:
    public void onModuleLoad() {
    
    		DynamicForm df1 = new DynamicForm();
    		final SelectItem field1 = new SelectItem();
    		field1.setValueField("f_schueler_id");
    		field1.setDisplayField("f_name");
    		field1.setAutoFetchData(false);
    		field1.setOptionDataSource(DataSource.get("table"));
    		df1.setFields(field1);
    
    		DynamicForm df2 = new DynamicForm();
    		final SelectItem field2 = new SelectItem();
    		field2.setValueField("f_schueler_id");
    		field2.setDisplayField("f_name");
    		field2.setAutoFetchData(false);
    		field2.setOptionDataSource(DataSource.get("table"));
    		df2.setItems(field2);
    		
    		VLayout vlayout = new VLayout();
    		vlayout.addMember(df1);
    		vlayout.addMember(df2);
    		IButton button = new IButton("Click me");
    		button.addClickHandler(new ClickHandler() {
    
    			@Override
    			public void onClick(ClickEvent event) {
    				field1.fetchData(new DSCallback() {
    
    					@Override
    					public void execute(DSResponse dsResponse, Object data,
    							DSRequest dsRequest) {
    						if (dsResponse.getData().length >= 1) {
    							field1.setValue(dsResponse.getData()[0]
    									.getAttributeAsInt("f_schueler_id"));
    						}
    					}
    				});
    
    				field2.fetchData(new DSCallback() {
    
    					@Override
    					public void execute(DSResponse dsResponse, Object data,
    							DSRequest dsRequest) {
    						if (dsResponse.getData().length >= 2) {
    							field2.setValue(dsResponse.getData()[1]
    									.getAttributeAsInt("f_schueler_id"));
    						}
    					}
    				});
    			}
    		});
    		vlayout.addMember(button);
    		vlayout.draw();
    	}
    table.ds.xml
    Code:
    <DataSource ID="table" serverType="sql" tableName="t_schueler" 
    	 >
    
    	<fields>
    		<field name="f_schueler_id" type="sequence" primaryKey="true" />
    		<field name="f_name" type="text" required="true" />
    		
    	</fields>
    </DataSource>
    When you press the button, only one of the selectItems is correctly set (the second one, while the first one remains empty), and you get this error:
    Code:
    17:40:59.991 [ERROR] [zedes2V010214] 17:41:00.003:XRP3:WARN:The ResultSet's cache was invalidated while the following request was outstanding: {operationType: "fetch", dataSource: "table", data: Obj, callback: Obj, requestId: "table$6270", useStrictJSON: null, fallbackToEval: false, textMatchStyle: "startsWith", operationId: undef, startRow: 0, endRow: 75, sortBy: undef, resultSet: [ResultSet ID:isc_ResultSet_0 (created by: isc_PickListMenu_0)], componentId: "isc_PickListMenu_0", componentContext: "isc_DynamicForm_0.isc_SelectItem_0", showPrompt: false, internalClientContext: Obj, afterFlowCallback: Obj, operation: Obj{ID:table_fetch}, prompt: "Suche Datensätze die den Kriterien entsp..."[49], willHandleError: true, lastClientEventThreadCode: "MUP6", parentNode: null, bypassCache: true, unconvertedDSRequest: Obj, jsonReviver: DataSource.jsonReviver(), oldValues: Obj}, request data:{}:isc_ResultSet_0 (created by: isc_PickListMenu_0):[object Object]
    com.smartgwt.client.core.JsObject$SGWT_WARN: 17:41:00.003:XRP3:WARN:The ResultSet's cache was invalidated while the following request was outstanding: {operationType: "fetch", dataSource: "table", data: Obj, callback: Obj, requestId: "table$6270", useStrictJSON: null, fallbackToEval: false, textMatchStyle: "startsWith", operationId: undef, startRow: 0, endRow: 75, sortBy: undef, resultSet: [ResultSet ID:isc_ResultSet_0 (created by: isc_PickListMenu_0)], componentId: "isc_PickListMenu_0", componentContext: "isc_DynamicForm_0.isc_SelectItem_0", showPrompt: false, internalClientContext: Obj, afterFlowCallback: Obj, operation: Obj{ID:table_fetch}, prompt: "Suche Datensätze die den Kriterien entsp..."[49], willHandleError: true, lastClientEventThreadCode: "MUP6", parentNode: null, bypassCache: true, unconvertedDSRequest: Obj, jsonReviver: DataSource.jsonReviver(), oldValues: Obj}, request data:{}:isc_ResultSet_0 (created by: isc_PickListMenu_0):[object Object]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:105)
        at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
        at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
        at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
        at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
        at java.lang.Thread.run(Thread.java:745)
    Using SmartGWT Power (v9.1p_2014-09-06/PowerEdition Deployment (built 2014-09-06)) with MSSQL 2014.

    #2
    Hi edulid,

    I'm not perfectly sure, but I think you should do the fetch() on the DynamicForm and not the SelectItems themself. SelectItems will also be loaded automatically then.

    Best regards,
    Blama

    Comment


      #3
      Why not? I don't have any datasource in both DynamicForms, and I don't need any datasource there. I only neet the selectItem to show some values from the table.

      I think this might be a bug... Isomorphic? can you reproduce the problem?

      Comment


        #4
        This one is assigned to a developer to check out. We'll follow up when we have more information (or questions, etc)

        Regards
        Isomorphic Software

        Comment


          #5
          Hi Isomorphic,

          any updates on this issue?

          Comment


            #6
            We've taken a look.
            The issue here is that by default SelectItems are set up to share the same drop down pick-list and share cached results wherever possible to avoid issuing more fetches against the DataSource than necessary.
            This is controlled by the cachePickListResults attribute.

            In this case your 2 SelectItems are sharing the pick-list, and you're explicitly issuing a fetch request against each of them, which ultimately leads to two fetches against the same ResultSet.

            When the second fetch is issued, the first request is still in progress, but the criteria are unchanged. The framework uses the "invalidateCache" flow to achieve the second fetch.

            Both your problems stem from this -- the warning is simply a notification letting you know that the cache has been invalidated during a fetch, and when this is done the dsResponse.data gets essentially emptied out as the data is assumed to not be the latest available set of data.

            To fix this, simply set cachePickListResults to true in your SelectItems.
            EDIT: correction: set cachePickListResults to *false*

            Regards
            Isomorphic Software
            Last edited by Isomorphic; 24 Sep 2014, 13:29. Reason: Corrected solution text

            Comment


              #7
              Thank you, the cachePickListResults worked!

              Comment


                #8
                I now get a similar message for a listGrid:

                Code:
                10:57:39.190:XRP6:WARN:The ResultSet's cache was invalidated while the following request was outstanding: {operationType: "fetch", dataSource: "vertraege", data: Obj, callback: Obj, requestId: "vertraege$62767", useStrictJSON: null, fallbackToEval: false, textMatchStyle: "exact", operationId: undef, startRow: 0, endRow: 75, sortBy: Array[2], resultSet: [ResultSet ID:isc_ResultSet_17 (created by: isc_VertraegeListGrid_1)], componentId: "isc_VertraegeListGrid_1", componentContext: undef, operation: Obj{ID:vertraege_fetch}, prompt: "Suche Datensätze die den Kriterien entsp..."[49], internalClientContext: Obj, willHandleError: true, afterFlowCallback: afterFlowCallback(), lastClientEventThreadCode: "XRP2", parentNode: null, bypassCache: true, showPrompt: true, unconvertedDSRequest: Obj, jsonReviver: DataSource.jsonReviver(), oldValues: Obj}, request data:{f_schueler_id: 7356}:isc_ResultSet_17 (created by: isc_VertraegeListGrid_1):[object Object]
                com.smartgwt.client.core.JsObject$SGWT_WARN: 10:57:39.190:XRP6:WARN:The ResultSet's cache was invalidated while the following request was outstanding: {operationType: "fetch", dataSource: "vertraege", data: Obj, callback: Obj, requestId: "vertraege$62767", useStrictJSON: null, fallbackToEval: false, textMatchStyle: "exact", operationId: undef, startRow: 0, endRow: 75, sortBy: Array[2], resultSet: [ResultSet ID:isc_ResultSet_17 (created by: isc_VertraegeListGrid_1)], componentId: "isc_VertraegeListGrid_1", componentContext: undef, operation: Obj{ID:vertraege_fetch}, prompt: "Suche Datensätze die den Kriterien entsp..."[49], internalClientContext: Obj, willHandleError: true, afterFlowCallback: afterFlowCallback(), lastClientEventThreadCode: "XRP2", parentNode: null, bypassCache: true, showPrompt: true, unconvertedDSRequest: Obj, jsonReviver: DataSource.jsonReviver(), oldValues: Obj}, request data:{f_schueler_id: 7356}:isc_ResultSet_17 (created by: isc_VertraegeListGrid_1):[object Object]
                    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
                    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
                    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
                    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
                    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:105)
                    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
                    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
                    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
                    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
                    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
                    at java.lang.Thread.run(Thread.java:745)
                Is there a similar method for a listGrid? I didn't find something similar.

                Comment


                  #9
                  For a ListGrid the situation is probably simpler - something is calling 'invalidateCache' on the ListGrid (or, less likely, directly on the ResultSet) - while a fetch is in progress.
                  This is probably safe to ignore (we've actually demoted this warning to an info level log in more recent builds), but could indicate that you're doing more fetches than are necessary.
                  The most likely cause is some application code which calls the invalidateCache method directly. If you can find the code snippet which trips this warning you can probably determine whether the invalidateCache call is really required.

                  If this doesn't give you enough information to debug this, we'd need a way to reproduce

                  Regards
                  Isomorphic Software

                  Comment

                  Working...
                  X