Если вы используете Smart GWT LGPL:
Пожалуйста, прочитайте Javadocs RestDataSource, поскольку это объясняет это подробно: http://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/data/RestDataSource.html
Также взгляните на образец RestDataSource: http://www.smartclient.com/smartgwt/showcase/#featured_restfulds
Если вы используете Smart GWT EE, то
1) Если вы используете соединитель SQL, у вас есть 0 кодов для записи на сервере, так как код на стороне сервера Smart GWT позаботится о связывании данных с таблицей базы данных.
2) Если вам требуется управление режимом привязки данных сервера, вы можете использовать свой собственный API-интерфейс сервера при прокрутке (выборке) или при вставке / обновлении / удалении. Посмотрите на источник этого образца: http://www.smartclient.com/smartgwtee/showcase/#javabeans
Нажмите кнопку View Source и проверьте источник для класса SupplyItemDMI. Обратите внимание, как вы можете получить начальную строку, параметры конечной строки запроса.
// By default, for a DSRequest of type "fetch", a method named "fetch" is invoked.
// You can customize this via the <serverObject> declaration.
public DSResponse fetch(DSRequest dsRequest)
throws Exception {
log.info("procesing DMI fetch operation");
// Fetch a List of matching SupplyItem Beans from some pre-existing Java object model
// provided by you, represented by "SupplyItemStore" in this example
List matchingItems =
SupplyItemStore.findMatchingItems((Long) dsRequest.getFieldValue("itemID"),
(String) dsRequest.getFieldValue("itemName"));
// this implementation shows data paging (returning only ranges of requested records)
long startRow = dsRequest.getStartRow();
long endRow = dsRequest.getEndRow();
long totalRows = matchingItems.size();
DSResponse dsResponse = new DSResponse();
dsResponse.setTotalRows(totalRows);
dsResponse.setStartRow(startRow);
endRow = Math.min(endRow, totalRows);
dsResponse.setEndRow(endRow);
// trim the data to the requested range of records. In a real application, the startRow
// and endRow would be passed to the ORM layer or to SQL for maximum efficiency.
List results;
if (totalRows > 0) {
results = matchingItems.subList((int) dsResponse.getStartRow(),
(int) dsResponse.getEndRow());
} else {
results = matchingItems;
}
// just return the List of matching beans
dsResponse.setData(results);
return dsResponse;
}