Announcement

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

    DataSource fetch method called twice

    Upgrade SmartGWT from 1.3 to 2.5
    GWt 2.0.4, GWT-SL0.1.5

    PagedDataSource extends GwtDataSource extends DataSource
    Code:
    @Override
    protected void executeFetch(final String requestId, final DSRequest request, final DSResponse response) {
    	int pageNumber = 0;
    	if (pagingCanvas != null)
    		pageNumber = pagingCanvas.getCurrentPage();
    	
            String sortBy = request.getAttribute("sortBy");
    
            if (!isSortByMatches(sortBy, lastSortBy)) {
    	     pageNumber = 1;
    	}
    	lastSortBy = sortBy;
    				
    	executePagedFetch(createSearchVo(sortBy, pageNumber), requestId, request, response);
    }
    ContentProviderDataSource extends PagedDataSource
    Code:
    @Override
    public void executePagedFetch(SearchVo searchVo,  final String requestId, final DSRequest request, final DSResponse response) {		
    	AsyncCallback<PagingVO<ContentVO>> callBack = new AsyncCallback<PagingVO<ContentVO>>() {
    
    		@Override
    		public void onFailure(Throwable exception) {
    			myApp.closeWaitDialog();
    			setPagedFetchFailed(requestId, request, response, exception);
    			MyGwtExceptionHandler.alertException(this.getClass(), exception);
    		}
    
    		@Override
    		public void onSuccess(PagingVO<ContentVO> result) {
    			myApp.closeWaitDialog();
    			setPagedFetchResults(requestId, request, response, result);
    		}
    	};
    	myApp.openWaitDialog();
    }
    By put the break point, I found the onSuccess method was called multiple times. After first 5 rows were shown, the ContentGrid is refreshed itself and the second set of same data attached to the ContentGrid.

    I use the contentGrid.invalidateCache() before the call reaches the method executeFetch from the PagedDataSource. The invalidateCache() only reaches once.

    Please help.
    Thanks a lot.
    James.
    Attached Files
    Last edited by jmke9998; 25 Aug 2011, 12:42.

    #2
    I'm not sure if this is the cause, but try to set for your listgrid:
    Code:
    tableGrid.setDataFetchMode(FetchMode.BASIC);
    I've had similar problem with multiple fetch requests after upgrade to smartGWT2.5. It seems, there is set FetchMode.PAGED as the default value...

    Comment

    Working...
    X