This may well be how I am using the ResultSet, but I would very much like to know how to use this correctly.
Expected: resultSet listeners are fired when edits are made to the ListGrid
Observed: no calls to the handlers are made
I want to use the ResultSet handlers to trigger UI component updates (ie, buttons changing/etc) but I've tried numerous ways and can't seem to find out how to make ResultSet work. All I need is an event listener that triggers when the underlying dataset changes.
Expected: resultSet listeners are fired when edits are made to the ListGrid
Observed: no calls to the handlers are made
I want to use the ResultSet handlers to trigger UI component updates (ie, buttons changing/etc) but I've tried numerous ways and can't seem to find out how to make ResultSet work. All I need is an event listener that triggers when the underlying dataset changes.
Code:
private static DataSource getData() { DataSource dataSource = new DataSource(); dataSource.setClientOnly(true); DataSourceField keyField = new DataSourceField("1", FieldType.TEXT); keyField.setPrimaryKey(true); dataSource.addField(keyField); dataSource.addField(new DataSourceField("2", FieldType.TEXT)); dataSource.addField(new DataSourceField("3", FieldType.TEXT)); return dataSource; } private static void generate(DataSource dataSource, int count) { ArrayList<ListGridRecord> records = new ArrayList<ListGridRecord>(); for (int i = 0; i < count; i++) { ListGridRecord record2 = new ListGridRecord(); record2.setAttribute("1", "id " + i); record2.setAttribute("2", "e" + Random.nextInt(10)); record2.setAttribute("3", "f" + Random.nextInt(3)); records.add(record2); } dataSource.setTestData(records.toArray(new ListGridRecord[] {})); } public static void testResultSet() { DataSource ds = getData(); generate(ds,10); DataArrivedHandler dataArrivedHandler = new DataArrivedHandler() { @Override public void onDataArrived(DataArrivedEvent event) { SC.say(event.toDebugString()); } }; DataChangedHandler dataChangedHandler = new DataChangedHandler() { @Override public void onDataChanged(DataChangedEvent event) { SC.say(event.toDebugString()); } }; ResultSet rs = new ResultSet(ds); rs.addDataArrivedHandler(dataArrivedHandler); rs.addDataChangedHandler(dataChangedHandler); ListGrid listGrid = new ListGrid(); listGrid.setDataSource(ds); listGrid.setAutoFetchData(true); listGrid.setCanEdit(true); listGrid.setWidth100(); listGrid.setHeight100(); listGrid.show(); }
Comment