public class DataContext extends DataClass
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);
factoryCreated, factoryProperties
Constructor and Description |
---|
DataContext() |
DataContext(com.google.gwt.core.client.JavaScriptObject jsObj) |
Modifier and Type | Method and Description |
---|---|
DataContext |
addDataSourceRecord(java.lang.String dataSourceID,
Record record) |
java.util.Set<java.lang.String> |
getBoundDataSources()
Returns set of all DataSource IDs currently bound for this DataContext.
|
Record |
getDataSourceRecord(DataSource dataSource)
Returns record bound to the DataSource.
|
Record |
getDataSourceRecord(java.lang.String dataSourceID)
Returns record bound to the DataSource.
|
java.util.Map<java.lang.String,java.lang.Object> |
getDataSourceRecordBindings()
Returns all current DataSource-to-Record and DataSource-to-Record[] bindings for this
DataContext.
|
java.lang.Object |
getDataSourceRecords(DataSource dataSource)
Returns record(s) bound to the DataSource as Record or Record[].
|
java.lang.Object |
getDataSourceRecords(java.lang.String dataSourceID)
Returns record(s) bound to the DataSource as Record or Record[].
|
static DataContext |
getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj) |
java.lang.Object |
getSharedJavaObject(java.lang.String id)
Returns the POJO bound to this id.
|
java.lang.Object |
removeDataSourceRecords(DataSource dataSource)
Removes any record binding(s) for the DataSource.
|
java.lang.Object |
removeDataSourceRecords(java.lang.String dataSourceID)
Removes any record binding(s) for the DataSource.
|
DataContext |
setDataSourceRecord(DataSource dataSource,
Record record)
Binds the DataSource to the supplied record.
|
DataContext |
setDataSourceRecord(java.lang.String dataSourceID,
Record record)
Binds the DataSource to the supplied record.
|
DataContext |
setDataSourceRecords(DataSource dataSource,
Record... record)
Binds the DataSource to the supplied records, as an array.
|
DataContext |
setDataSourceRecords(java.lang.String dataSourceID,
Record... record)
Binds the DataSource to the supplied records, as an array.
|
DataContext |
setSharedJavaObject(java.lang.String id,
java.lang.Object sharedObject)
Binds the id to the supplied POJO.
|
applyFactoryProperties, 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
public DataContext()
public DataContext(com.google.gwt.core.client.JavaScriptObject jsObj)
public static DataContext getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj)
public DataContext setDataSourceRecord(DataSource dataSource, Record record)
dataSource
- record
- DataContext
instance, for
chaining setter callspublic DataContext setDataSourceRecord(java.lang.String dataSourceID, Record record)
dataSourceID
- record
- DataContext
instance, for
chaining setter callspublic DataContext setDataSourceRecords(DataSource dataSource, Record... record)
dataSource
- record
- DataContext
instance, for
chaining setter callspublic DataContext setDataSourceRecords(java.lang.String dataSourceID, Record... record)
dataSource
- record
- DataContext
instance, for
chaining setter callspublic DataContext addDataSourceRecord(java.lang.String dataSourceID, Record record)
public java.lang.Object getDataSourceRecords(DataSource dataSource)
dataSource
- public java.lang.Object getDataSourceRecords(java.lang.String dataSourceID)
dataSourceID
- public Record getDataSourceRecord(DataSource dataSource)
dataSource
- public Record getDataSourceRecord(java.lang.String dataSourceID)
dataSourceID
- public java.lang.Object removeDataSourceRecords(DataSource dataSource)
dataSource
- public java.lang.Object removeDataSourceRecords(java.lang.String dataSourceID)
dataSourceID
- public DataContext setSharedJavaObject(java.lang.String id, java.lang.Object sharedObject)
Passing POJOs to a child window via this API is "super experimental" (beyond the feature itself, which is experimental). To support this, you must declare the "typeSync" linker in your GWT project:
<add-linker name="typeSync"/>
id
- identifier for POJOsharedobject
- POJO to bindDataContext
instance, forpublic java.lang.Object getSharedJavaObject(java.lang.String id)
Passing POJOs to a child window via this API is "super experimental" (beyond the feature itself, which is experimental). To support this, you must declare the "typeSync" linker in your GWT project:
<add-linker name="typeSync"/>
id
- identifier for POJOpublic java.util.Map<java.lang.String,java.lang.Object> getDataSourceRecordBindings()
public java.util.Set<java.lang.String> getBoundDataSources()