SelectIem issue with fetch from datasource

I am having an issue having a SelectItem fetch data from a DataSource unless fetchData called. (Calling setAutoFetchData(true) also fails to fetch data)

The datasource is fetching data from a Web Service.

In this code sample once the page loads and I click on the SelectItem drop down I can see there is no call made to the DataSource.

public class Test implements EntryPoint {
	public void onModuleLoad() {
		final DynamicForm form = new DynamicForm();
		form.setWidth(500);
		form.setNumCols(4);

		DataSource menuDS = MenuDS.getInstance();
        final SelectItem menuSelect = new SelectItem();  
        menuSelect.setOptionDataSource(menuDS);  
        
        menuSelect.setValueField("menuId");
        menuSelect.setDisplayField("menuName");
        menuSelect.setPickListWidth(210);  
        menuSelect.setTitle("Menu"); 
		form.setItems(menuSelect);
		form.draw();
		
	}
}

DataSource

public class MenuDS extends DataSource {

    private static MenuDS instance = null;
    private WebService menuService;
    public static MenuDS getInstance() {
        if (instance == null) {
            instance = new MenuDS("menuDS");
        }
        return instance;
    }

    public MenuDS(String id) {

		XMLTools
		.loadWSDL(
				"http://localhost:8080/testservice/test?wsdl",
				new WSDLLoadCallback() {
					public void execute(WebService webService) {
						menuService = webService;

					}
				});	    	
    	setID(id);
        setServiceNamespace("http://service.test.com/menu");
      
        DataSourceIntegerField menuId = new DataSourceIntegerField("menuId", "Menu ID");  
        menuId.setHidden(true);
        DataSourceTextField desc = new DataSourceTextField("menuName", "Name",50);  
        DataSourceTextField name = new DataSourceTextField("menuDesc", "Desc",250);  
  
        setFields(menuId, name, desc);   
        menuId.setPrimaryKey(true);
        
        setRecordName("menu");
        
        
        final OperationBinding fetchMenu = new OperationBinding();
		fetchMenu.setOperationType(DSOperationType.FETCH);
		fetchMenu.setWsOperation("listMenus");
		
		final OperationBinding updateMenu = new OperationBinding();
		updateMenu.setOperationType(DSOperationType.UPDATE);
		updateMenu.setWsOperation("updateMenu");

		final OperationBinding removeMenu = new OperationBinding();
		removeMenu.setOperationType(DSOperationType.REMOVE);
		removeMenu.setWsOperation("deleteMenu");		
		removeMenu.setUseFlatFields(true);
		
		final OperationBinding addMenu = new OperationBinding();
		addMenu.setOperationType(DSOperationType.ADD);
		addMenu.setWsOperation("createMenu");
		addMenu.setUseFlatFields(true);
		
		
		setOperationBindings(fetchMenu, addMenu, updateMenu, removeMenu);		
		setDataFormat(DSDataFormat.XML);             
        
    }
    
    public void transformResponse(DSResponse response, DSRequest request, Object data){
    	if (request.getOperationType().equals(DSOperationType.FETCH)){
    		return;
    	}
    	else if (request.getOperationType().equals(DSOperationType.UPDATE)){
    		return;
    	}
    	else if (request.getOperationType().equals(DSOperationType.REMOVE)){
    		return;
    	}    	
    	else if (request.getOperationType().equals(DSOperationType.ADD)){
    	    JavaScriptObject[] errorNodes = getNodeObjects(data, "//return/errors");
    	    
    	    if(errorNodes != null) {
                response.setStatus(RPCResponse.STATUS_VALIDATION_ERROR);  
                JavaScriptObject responseErrors = JSOHelper.createObject();
                
                for(int x = 0; x < errorNodes.length; x++) {
                    // TODO This does not currently handle multiple messages for the same field
                    SC.logEchoAll(errorNodes[x], "jsError");

                    String message = JSOHelper.getAttribute(errorNodes[x], "message");
                    String property = JSOHelper.getAttribute(errorNodes[x], "property");                    
                    JSOHelper.setAttribute(responseErrors, property, message);
                }
                
                response.setErrors(responseErrors);
    	    }
    	    else {
                errorNodes = getNodeObjects(data, "//env:Fault");
                if(errorNodes != null) {
                    response.setStatus(RPCResponse.STATUS_FAILURE);
                    SC.warn(JSOHelper.getAttribute(errorNodes[0], "faultstring"), new BooleanCallback(){public void execute(Boolean value) {}});
                    SC.logEchoAll(errorNodes[0], "jsError");
                }
    	    }    		
    	}
    }
    
    private JavaScriptObject[] getNodeObjects(Object data, String xpath) {
        JavaScriptObject nodes = (JavaScriptObject) XMLTools.selectNodes(data, xpath);
        SC.logEchoAll(nodes, "nodes");

        JavaScriptObject[] jsNodeArray = null;
        
        int nodeCount = JSOHelper.getArrayLength(nodes);
        if(nodeCount > 0) {
            JavaScriptObject jsNodes = (JavaScriptObject)XMLTools.toJS(nodes);
            SC.logEchoAll(jsNodes, "jsNodes");
            jsNodeArray = JSOHelper.toArray(jsNodes);
        }
        return jsNodeArray;
    }
}

If I add a button in to call fetchData the Web Service is called and the SelectItem is populated correctly

		IButton loadButton = new IButton("Load Data");
		loadButton.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				menuSelect.fetchData();
				
			}
		});

I suspect there is something elementary I am missing.

SelectItems will cache previous server responses. Is there a request the first time ever that this SelectItem is used? Perhaps that has a blank set of results from the service.

By switching to a client datasource the SelectItem does have the correct data the first time it is used. This lead me to believe there was an issue with the web service datasource. This issue is I am trying to use the datasource before loading the WSDL. Once I moved the call to load the WSDL into onModuleLoad the data is initialized correctly.

yes, the call XMLTools.loadWSDL is asynchronous you you should either load this earlier in your app, or drive the DataSource controlling logic from the WSDLLoadCallback.

Sanjiv