DataSource.java revision ee4baa6495590c14c933f1fafa37d1843bbee996
1package afeclient.client.table; 2 3import com.google.gwt.json.client.JSONArray; 4import com.google.gwt.json.client.JSONObject; 5 6public interface DataSource { 7 public static final int ASCENDING = 1, DESCENDING = -1; 8 9 public interface DataCallback { 10 public void onGotData(int totalCount); 11 public void handlePage(JSONArray data); 12 } 13 14 public class DefaultDataCallback implements DataCallback { 15 public void onGotData(int totalCount) {} 16 public void handlePage(JSONArray data) {} 17 } 18 19 /** 20 * Update the data source with the given filtering parameters. After 21 * completion, callback.onGotData() will be called with the total number 22 * of results maching the given parameters. 23 * 24 */ 25 public void updateData(JSONObject params, final DataCallback callback); 26 27 /** 28 * Get a page of data. After completion, callback.handlePage() will be 29 * called with the data. 30 * @param start row to start with (for pagination) 31 * @param maxCount maximum rows to be returned 32 * @param sortOn column name to sort on 33 * @param sortDirection ASCENDING or DESCENDING 34 */ 35 public void getPage(Integer start, Integer maxCount, 36 String sortOn, Integer sortDirection, 37 final DataCallback callback); 38 39 /** 40 * Get the total number of results match the most recent updateData call. 41 */ 42 public int getNumResults(); 43} 44