public interface DsFacade
DSRequests
by passing them on to another DataSource.
This can be useful for:
cacheAllData
or automatic caching
done by ResultSet
DataSourceField.includeFrom
if you have Smart GWT Pro or better)
operationId
for this)
This facade pattern can be implemented either server-side or client-side:
dataProtocol:"clientCustom"
. The
FacadeDataSource
provides a specific implementation that is
useful for testing
purposes. Alternative, the code below shows the simplest possible code for the facade
pattern when implemented client-side via dataProtocol:"clientCustom"
- requests
are forwarded to another DataSource, and the responses are returned completely unchanged.
final DataSource facadeDataSource = new DataSource() { { setDataProtocol(DSProtocol.CLIENTCUSTOM); setInheritsFrom(ItemSupplyXmlDS.getInstance()); } @Override public Object transformRequest(final DSRequest dsRequest) { final DataSource superDS = DataSource.get(getInheritsFrom()), selfDS = this; final DSRequest derivedDSRequest = cloneDSRequest(dsRequest); derivedDSRequest.setShowPrompt(false); derivedDSRequest.setCallback(new DSCallback() { @Override public void execute(DSResponse dsResponse, Object data, DSRequest derivedDSRequest) { selfDS.processResponse(dsRequest.getRequestId(), superDS.cloneDSResponse(dsResponse)); } }); superDS.execute(derivedDSRequest); return dsRequest.getData(); } };