Announcement

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

    Bug when sharing operationIds over multiple datasources

    My case to reproduce this is a bit weird but it was quite hard to get this reproduced in a sort of minimal example. Given the following fragment of code: I start with creating two ListGrids with the same fetchOperationId and then destroying them. Then i recreate those two, for the first one it goes ok, but the second one will fetch on the datasource of the first.

    So to reproduce this use these buttons:

    1) Create Content (first DataSource)
    2) Create Customer (second DataSource)
    3) Destroy Content grid
    4) Destroy Customer Grid
    5) Create Content
    6) Create Customer

    Now you should see see the Customer grid fetches on the Content datasource for some reason.

    I tested this on : SC_SNAPSHOT-2011-06-30/PowerEdition Deployment (built 2011-06-30), FireFox 4 with GWT 2.1.0. And also on a nightly from around the start of may. Both gave this bug.

    I didnt attach the datasources because they are irrelevant.

    Code:
    package test.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.widgets.Canvas;
    import com.smartgwt.client.widgets.IButton;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.layout.HLayout;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    public class OperationIdTest implements EntryPoint {
    	
    	private HLayout gridCanvasCollection;
    	private HLayout buttons;
    	
    	public void onModuleLoad() {
    		buttons = new HLayout();
    		IButton createContentGrid = new IButton("Create Content");
    		createContentGrid.addClickHandler(new ClickHandler() {
    			@Override
    			public void onClick(ClickEvent event) {
    				createGridCanvas(DataSource.get("contents"));
    			}
    		});
    		IButton createCustomerGrid = new IButton("Create Customer");
    		createCustomerGrid.addClickHandler(new ClickHandler() {
    			@Override
    			public void onClick(ClickEvent event) {
    				createGridCanvas(DataSource.get("Customer"));
    			}
    		});
    		buttons.addMember(createContentGrid);
    		buttons.addMember(createCustomerGrid);
    		
    		gridCanvasCollection = new HLayout();
    		
    		VLayout mainCanvas = new VLayout();
    		mainCanvas.addMember(buttons);
    		mainCanvas.addMember(gridCanvasCollection);
    		mainCanvas.setWidth100();
    		mainCanvas.setHeight100();
    		mainCanvas.draw();
    	}
    	
    	private void createGridCanvas(DataSource ds) {
    		final Canvas grid = createGrid(ds);
    		final IButton destroyButton = new IButton("Destroy " + ds.getID());
    		destroyButton.addClickHandler(new ClickHandler() {
    			@Override
    			public void onClick(ClickEvent event) {
    				grid.destroy();
    				destroyButton.destroy();
    			}
    		});
    		gridCanvasCollection.addMember(grid);
    		buttons.addMember(destroyButton);
    	}
    	
    	private ListGrid createGrid(DataSource ds) {
    		ListGrid listGrid = new ListGrid();
    		listGrid.setAutoFetchData(true);
    		listGrid.setDataSource(ds);
    		listGrid.setFetchOperation("fakeOperationId");
    		return listGrid;
    	}
    
    }

    #2
    operationIds do indeed need to be unique across DataSources. We plan to relax this requirement in the future, but for now, use unique IDs.

    Comment


      #3
      Any chance this could be in 2.5? We actually share an operationId over a lot of our datasources (basically "fetchSomeExtraValues"), so "for now, use unique IDs." is not as easy as it sounds. The requirement also does not make a lot of sense to me.

      http://www.smartclient.com/smartgwtee/javadoc/com/smartgwt/client/docs/DsRequestEquivalence.html also has no mention of this.

      Comment


        #4
        Sorry, not really possible. You can use the DataSource ID as a prefix since that's already unique.

        Comment

        Working...
        X