Announcement

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

    setTestData doesn't work in browser

    Hallo,

    I would like to populate a client only datasource (clientOnlyDS) from a databound RestDataSource (boundDS) und use clientOnlyDS as source for a grid.
    Here is my simple testcase:
    Code:
    	public void onModuleLoad() {
    		DataSource boundDS = createDataSource();
    		final RestDataSource clientOnlyDS = new RestDataSource();
    		clientOnlyDS.setInheritsFrom(boundDS);
    		clientOnlyDS.setClientOnly(true);
    		final ListGrid grid = new ListGrid();
    		grid.setWidth(400);
    		grid.setDataSource(clientOnlyDS);
    		grid.setAutoFetchData(false);
    		grid.draw();
    		
    		boundDS.fetchData(null, new DSCallback() {
    			@Override
    			public void execute(DSResponse response, Object rawData,
    					DSRequest request) {
    				clientOnlyDS.setTestData(response.getData());
    				grid.setData(new ListGridRecord[0]);
    				grid.fetchData();
    			}
    			
    		});
    	}
    	
    	private DataSource createDataSource() {
    		RestDataSource source = new RestDataSource();
    		source.setDataFormat(DSDataFormat.XML);
    		DataSourceTextField dsfPlayerId = new DataSourceTextField("id", "id");
    		dsfPlayerId.setPrimaryKey(true);
    		dsfPlayerId.setHidden(true);
    		DataSourceTextField dsfName = new DataSourceTextField("name", "name");
    		DataSourceIntegerField dsfSex = new DataSourceIntegerField("sex", "sex");
    		DataSourceIntegerField dsfBirth = new DataSourceIntegerField("yearofbirth", "Year ob birth");
    		source.setFields(dsfPlayerId, dsfName, dsfSex, dsfBirth);
    		source.setFetchDataURL("data.xml");
    		return source;
    	}
    where my test data (data.xml) looks like this:
    Code:
    <response>
      <status>0</status>
      <totalrows>3</totalrows>
      <data>
        <record>
            <id>1018</id>
            <name>Mustermann, Paul</name>
            <sex>M</sex>
            <yearofbirth>1992</yearofbirth>
        </record>
        <record>
            <id>169</id>
            <name>Doe, John</name>
            <sex>M</sex>
            <yearofbirth>1994</yearofbirth>
        </record>
        <record>
            <id>167</id>
            <name>Müller, Ernst</name>
            <sex>M</sex>
            <yearofbirth>1989</yearofbirth>
        </record>
      </data>
    </response>
    In Hosted mode the grid is populated without any problem. But if I compile the code and try it in the browser, the grid is drawn, but stays empty, saying "loading data ...". According to firebug, data.xml is loaded but the grid doesn't fetch its data. This happens even, if I put grid.draw() at the end of onModuleLoad(). The problem occurs in Firefox 3.5.5 as well as in IE 8.
    Where is my mistake?

    #2
    *bump*
    Really nobody any idea? I would be really happy!

    Thanks, Chris

    Comment

    Working...
    X