Package com.smartgwt.client.widgets
Class DataContext
java.lang.Object
com.smartgwt.client.core.JsObject
com.smartgwt.client.core.DataClass
com.smartgwt.client.widgets.DataContext
- All Implemented Interfaces:
- HasHandlers
A mapping from 
DataSource IDs to specific Records.
  
  To understand how dataContext is used to automatically populate
 DataBoundComponents, see Canvas.autoPopulateData.
  
  
  
For example, in SmartGWT:
    Record customerRecord = new Record();
    customerRecord.setAttribute("customerNumber", "15");
    customerRecord.setAttribute("name", "Trish Joiner");
 
    Record employeeRecord = new Record();
    employeeRecord.setAttribute("employeeID", "4231");
    employeeRecord.setAttribute("name", "Fred Smith");
 
    DataContext dataContext = new DataContext();
    dataContext.addMapping("Customer", customerRecord);
    dataContext.addMapping("Employee", employeeRecord);
  - 
Field SummaryFields inherited from class com.smartgwt.client.core.DataClassfactoryCreated, factoryProperties
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionaddDataSourceRecord(String dataSourceID, Record record) Returns set of all DataSource IDs currently bound for this DataContext.getDataSourceRecord(DataSource dataSource) Returns record bound to the DataSource.getDataSourceRecord(String dataSourceID) Returns record bound to the DataSource.Returns all current DataSource-to-Record and DataSource-to-Record[] bindings for this DataContext.getDataSourceRecords(DataSource dataSource) Returns record(s) bound to the DataSource as Record or Record[].getDataSourceRecords(String dataSourceID) Returns record(s) bound to the DataSource as Record or Record[].static DataContextgetOrCreateRef(JavaScriptObject jsObj) Returns the POJO bound to this id.removeDataSourceRecords(DataSource dataSource) Removes any record binding(s) for the DataSource.removeDataSourceRecords(String dataSourceID) Removes any record binding(s) for the DataSource.setDataSourceRecord(DataSource dataSource, Record record) Binds the DataSource to the supplied record.setDataSourceRecord(String dataSourceID, Record record) Binds the DataSource to the supplied record.setDataSourceRecords(DataSource dataSource, Record... record) Binds the DataSource to the supplied records, as an array.setDataSourceRecords(String dataSourceID, Record... record) Binds the DataSource to the supplied records, as an array.setSharedJavaObject(String id, Object sharedObject) Binds the id to the supplied POJO.Methods inherited from class com.smartgwt.client.core.DataClassapplyFactoryProperties, doAddHandler, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsDoubleArray, getAttributeAsElement, getAttributeAsFloat, getAttributeAsInt, getAttributeAsIntArray, getAttributeAsJavaScriptObject, getAttributeAsLong, getAttributeAsMap, getAttributeAsObject, getAttributeAsRecord, getAttributeAsString, getAttributeAsStringArray, getAttributes, getHandlerCount, isFactoryCreated, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributeAsJavaObject, setFactoryCreated
- 
Constructor Details- 
DataContextpublic DataContext()
- 
DataContext
 
- 
- 
Method Details- 
getOrCreateRef
- 
setDataSourceRecordBinds the DataSource to the supplied record.- Parameters:
- dataSource-
- record-
- Returns:
- DataContextinstance, for chaining setter calls
 
- 
setDataSourceRecordBinds the DataSource to the supplied record.- Parameters:
- dataSourceID-
- record-
- Returns:
- DataContextinstance, for chaining setter calls
 
- 
setDataSourceRecordsBinds the DataSource to the supplied records, as an array.- Parameters:
- dataSource-
- record-
- Returns:
- DataContextinstance, for chaining setter calls
 
- 
setDataSourceRecordsBinds the DataSource to the supplied records, as an array.- Parameters:
- dataSource-
- record-
- Returns:
- DataContextinstance, for chaining setter calls
 
- 
addDataSourceRecord
- 
getDataSourceRecordsReturns record(s) bound to the DataSource as Record or Record[].- Parameters:
- dataSource-
- Returns:
- bound record(s), or null
 
- 
getDataSourceRecordsReturns record(s) bound to the DataSource as Record or Record[].- Parameters:
- dataSourceID-
- Returns:
- bound record(s), or null
 
- 
getDataSourceRecordReturns record bound to the DataSource. If an array of records is bound to the DataSource, returns the first one.- Parameters:
- dataSource-
- Returns:
- bound record, or null
 
- 
getDataSourceRecordReturns record bound to the DataSource. If an array of records is bound to the DataSource, returns the first one.- Parameters:
- dataSourceID-
- Returns:
- bound record, or null
 
- 
removeDataSourceRecordsRemoves any record binding(s) for the DataSource.- Parameters:
- dataSource-
- Returns:
- bound record(s), or null
 
- 
removeDataSourceRecordsRemoves any record binding(s) for the DataSource.- Parameters:
- dataSourceID-
- Returns:
- bound record(s), or null
 
- 
getDataSourceRecordBindingsReturns all current DataSource-to-Record and DataSource-to-Record[] bindings for this DataContext.- Returns:
- map of DataSource IDs to records
 
- 
getBoundDataSourcesReturns set of all DataSource IDs currently bound for this DataContext.- Returns:
- bound DataSource IDs
 
 
-