|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ClientOnlyDataSources
The client-side interface to a client-only DataSource is identical to a server-based DataSource, including asynchronous responses, so that a client-only DataSource can be replaced by a server-based DataSource without code changes. The only difference is that changes to records belonging to the DataSource persist only until the page is reloaded.
Client-only DataSources allow you to create a complete prototype application in an .html file that does not require a server.
The clientOnly
property is specified to create a client-only DataSource, and
the testData
property should contain the
test dataset, as an Array of Objects,
one per DataSource record. For example:
isc.DataSource.create({ ID:"supplyItem", fields: ..., clientOnly:true, testData:[ {itemName:"Pencil", cost:5.50}, ... ] });If you have existing test data in XML (see the
'Admin Console'
for
expected format),
you can use the XML->JS translation engine to load it into a client-only DataSource, like
so:
isc.DataSource.create({ ID:"solutions", fields: ..., clientOnly : true, testData : <isomorphic:XML filename="shared/ds/test_data/solutions.data.xml"/> });Another useful practice is to specify both the clientOnly DataSource and it's test data in XML, so that the
'Admin Console'
can later be used to import the
DataSource and its test data into a SQL Database. An idiom for accomplishing this is:
<isomorphic:loadDS name="solutions"/> isc.DataSource.getDataSource("solutions").addProperties({ clientOnly : true, testData : <isomorphic:XML filename="shared/ds/test_data/solutions.data.xml"/> });Finally, if you specify your DataSource as
clientOnly: true
, omit testData
entirely, and provide either a dataURL
or a testFileName
, the
DataSource will lazily
make a one-time fetch against the specified data file the first time
an operation is called on it. From then on,
the DataSource will work against the local
cache created from this initial request. This is a quick way to
prototype against some test
data that may eventually be returned from an arbitrary back-end.
DataSource.getClientOnly()
,
DataSource.getTestData()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |