Class DataSource
This class is not meant to be created and used, it is actually documentation of settings
allowed in a DataSource descriptor (.ds.xml file), for use with Smart GWT Pro Edition and
above.
See com.smartgwt.client.docs.serverds
for how to use this documentation.
Each DataSource consists of a list of fields
that make up a DataSource
record
, along with field types
, validation
rules
, relationships
to
other DataSources, and other metadata.
The abstract object description provided by a DataSource is easily mapped to a variety of backend object models and storage schemes. The following table shows analogous terminology across systems.
Isomorphic Smart GWT | Relational Database | Enterprise Java Beans (EJB) | Entity/Relationship Modeling | OO/UML | XML Schema/WSDL | LDAP |
DataSource | Table | EJB class | Entity | Class | Element Schema (ComplexType) | Objectclass |
Record | Row | EJB instance | Entity instance | Class instance/Object | Element instance (ComplexType) | Entry |
Field | Column | Property | Attribute | Property/Attribute | Attribute or Element (SimpleType) | Attribute |
DataSources can be declared
in either JavaScript or XML format, and can also be imported
from existing metadata formats, including XML Schema.
Data Binding is the process by
which Data Binding-capable UI components
can automatically configure themselves for viewing, editing and saving data described by
DataSources. DataBinding is covered in the 'QuickStart Guide', Chapter 6, Data Binding.
Data Integration
is the process by
which a DataSource can be connected to server systems such as SQL DataBases, Java Object
models, WSDL web services and other data providers. Data Integration comes in two variants:
client-side and server-side. Server-side
integration
uses the Smart GWT Java-based server to connect to data represented by Java
Objects or JDBC-accessible databases. Client-side integration
connects Smart GWT DataSources to XML, JSON or other formats
accessible via HTTP.
DataSources have a concept of 4 core operations
("fetch", "add", "update" and
"remove") that can be performed on the set of objects represented by a DataSource. Once a
DataSource has been integrated with your data store, databinding-capable UI components can
leverage the 4 core DataSource operations to provide many complete user interactions without
the need to configure how each individual component loads and saves data.
These
interactions include grid views
, tree views
, detail views
, form
-based editing
and saving
, grid-based editing
and saving
, and custom interactions
provided by Pattern Reuse Example custom databinding-capable components.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionThe list of extra manually managed fields that will be added to thefields
of theAudit DataSource
.By default, all DataSources are assumed to be capable of handlingAdvancedCriteria
on fetch or filter type operations.This property indicates whether this DataSource supports aggregation/summarization of field values using thesummaryFunction
mechanism.If aDSRequest
arrives from the client that requestsserver-calculated summaries
, should it be allowed?Controls whetherAdvancedCriteria subqueries
are permitted for thisDataSource
.By default, custom dataSource implementations are assumed to be unable to supportdynamic tree joins
.This property indicates whether this DataSource supports referencees to related fields in criteria, either using qualified field names, or subqueries.Indicates the mode to use for resolving templated references in this DataSource's configuration file.With ordinarysimple criteria
, it is possible to provide an array of values for a given field, which means "any of these values".boolean
Enables saving of a log of changes to this DataSource in a second DataSource with the same fields, called the "audit DataSource".For DataSources withauditing enabled
, specifies the length of the field used to store the names of the fields which were updated.For DataSources withauditing enabled
, specifies the field name used to store the names of the fields which were updated.For DataSources withauditing enabled
, optionally specifies the ID of the audit DataSource.For DataSources withauditing enabled
, optionally specifies theserverConstructor
for the automatically generated audit DataSource.For audit DataSources, this required property specifies the ID of theaudited
DataSource.For DataSources withauditing enabled
, specifies the field name used to store the revision number for the change (in a field of type "sequence").For DataSources withauditing enabled
, specifies the field name used to store the timestamp when the operation was performed (in a field of type "datetime").For DataSources withauditing enabled
, specifies the field name used to store theoperationType
(in a field of type "text").For DataSources withauditing enabled
, specifies the field name used to store the user who performed the operation.For aRestConnector DataSource
, authentication details for the REST service.Whether to convert relative date values to concrete date values before sending to the server.boolean
SettingautoCreateAuditTable
totrue
indicates that audit DataSource will automatically create SQL table whenauditing
is enabled.This property allows you to specify that your DataSource's schema (field definitions) should be automatically derived from some kind of metadata.boolean
If set, titles are automatically derived fromfield.name
for any field that does not have afield.title
and is not markedhidden
:true, by calling the methodgetAutoTitle()
.If true, causes all operations on this DataSource to automatically start or join a transaction associated with the current HttpServletRequest.This property has different meanings depending on theserverType
:ThecacheSyncStrategy
to use for operations on this DataSource.ThecacheSyncTiming
to use for operations on this DataSource.Applies only to dataFormat: "json" anddataTransport
:"scriptInclude".By default, all DataSources are assumed to be capable of handlingServerSummaries
on fetch or filter type operations.boolean
When true, indicates that this DataSource supports multi-level sorting.fieldName for a field in the dataSource expected to contain an explicit array of child nodes.A clientOnly DataSource simulates the behavior of a remote data store by manipulating a static dataset in memory asDSRequests
are executed on it.int
Applies toSQL DataSources
only.boolean
Only applicable tobinary fields
onaudited
DataSources.For DataSources ofserverType
"hibernate", the name of a Spring bean to query to obtain Hibernate Configuration for this particular DataSource.Indicates that declarative security rules are waived for rows that were created by the current user.Decides under what conditions theResultSet
cache should be dropped when theResultSet.criteria
changes.Applies to RestConnector dataSources (serverType
"rest") only, and is overridable per operationBinding (seeOperationBinding.csvDelimiter
).Applies to RestConnector dataSources (serverType
"rest") only, and is overridable per operationBinding (seeOperationBinding.csvQuoteCharacter
).Name of the field that has the most pertinent numeric, date, or enum value, for use when aDataBoundComponent
needs to show a short summary of a record.Indicates the format to be used for HTTP requests and responses when fulfilling DSRequests (eg, whenfetchData()
is called).Transport to use for all operations on this DataSource.Default URL to contact to fulfill all DSRequests.For DataSources using theSmart GWT SQL engine
for persistence, which database configuration to use.ForserverType:"sql"
DataSources, sets the defaultsqlStorageStrategy
to use for boolean fields where nosqlStorageStrategy
has been declared on the field.Controls when primary keys are required for "update" and "remove" server operations, when allowMultiUpdate has not been explicitly configured on either theoperationBinding.allowMultiUpdate
or via the server-side APIDSRequest.setAllowMultiUpdate()
.For DataSources ofserverType
"sql" only, the name of a field to include in theORDER BY
clause as a means of enforcing a stable sort order, forpaged fetches
only.The default textMatchStyle to use forDSRequest
s that do not explicitly state atextMatchStyle
.Only applicable to "union" dataSources.An optional description of the DataSource's content.Name of the field that has a long description of the record, or has the primary text data value for a record that represents an email message, SMS, log or similar.Indicates that for server responses, for any data being interpreted as DataSource records, only data that corresponds to declared fields should be retained; any extra fields should be discarded.int
If we areloading progressively
, indicates the number of extra records Smart GWT Server will advertise as being available, if it detects that there are more records to view (seelookAhead
).The name of the property this DataSource uses for constant name when translating Java enumerated types to and from Javascript, if theEnumTranslateStrategy
is set to "bean".The name of the property this DataSource uses for ordinal number when translating Java enumerated types to and from Javascript, if theEnumTranslateStrategy
is set to "bean".Sets the strategy this DataSource uses to translate Java enumerated types (objects of type enum) to and from Javascript.The list of fields that compose records from this DataSource.The native field name used by this DataSource on the server to represent thefileContents
forFileSource Operations
.The native field name used by this DataSource on the server to represent thefileFormat
forFileSource Operations
.The native field name used by this DataSource on the server to representfileLastModified
forFileSource Operations
.The native field name used by this DataSource on the server to represent thefileName
forFileSource Operations
operations.The native field name used by this DataSource on the server to represent thefileType
forFileSource Operations
.The native field name used by this DataSource on the server to representfileVersion
forFileSource Operations
.For DataSources ofserverType
"sql" only, indicates whether we should automatically add a sort field forpaged fetches
on this DataSource.boolean
For anaudited
DataSource, controls whether the Framework will attempt to auto-generate the audit DataSource.Namespaces definitions to add to the root element of outbound XML messages sent to a web service, as a mapping from namespace prefix to namespace URI.Value to use for theownerIdField
if no one has authenticated.Applies to RestConnector dataSources (serverType
"rest") only, and is overridable per operationBinding (seeOperationBinding.headers
).Applies to RestConnector dataSources (serverType
"rest") only, and is overridable per operationBinding (seeOperationBinding.httpMethod
).Unique identifier for this DataSource.For JPA and Hibernate DataSources this property indicates, that data source has composite primary key and specifies fully-qualified Java class: with@EmbeddedId
you have to specify class name of declared id with@IdClass
you have to specify class specified in annotation declarationFor fields on this dataSource that specifyignoreTextMatchStyle
true, the prevailing textMatchStyle is ignored and Smart GWT matches exact values.Criteria that are implicitly applied to all fetches made through this DataSource.Name of the field that has the second most pertinent piece of textual information in the record, for use when aDataBoundComponent
needs to show a short summary of a record.For dataSources ofserverType
"sql" and "hibernate", specifies the inheritance mode to use.ID of another DataSource this DataSource inherits itsfields
from.Allows you to specify an arbitrary prefix string to apply to all json format responses sent from the server to this application.Allows you to specify an arbitrary suffix string to apply to all json format responses sent from the server to this application.Allows you to specify"add" operation
SQL query execution time threshold in milliseconds, which if exceeded query is identified as "slow" and may be logged under specific logging category.Allows you to specify"custom" operation
SQL query execution time threshold in milliseconds, which if exceeded query is identified as "slow" and may be logged under specific logging category.Allows you to specify"fetch" operation
SQL query execution time threshold in milliseconds, which if exceeded query is identified as "slow" and may be logged under specific logging category.Allows you to specify"remove" operation
SQL query execution time threshold in milliseconds, which if exceeded query is identified as "slow" and may be logged under specific logging category.Allows you to specify SQL query execution time threshold in milliseconds, which if exceeded query is identified as "slow" and may be logged under specific logging category.Allows you to specify"update" operation
SQL query execution time threshold in milliseconds, which if exceeded query is identified as "slow" and may be logged under specific logging category.int
If we areloading progressively
, indicates the number of extra records Smart GWT Server will read beyond the end record requested by the client, in order to establish if there are more records to view.Ifautomatic file versioning
is enabled for a FileSource DataSource, this property configures the maximum number of versions to retain.WhenmockMode
is enabled, criteria to use in an initial "fetch" DSRequest to retrieve sample data.WhenmockMode
is enabled, number of rows of data to retrieve via an initial "fetch" DSRequest, for use as sample data.For dataSources ofserverType
"sql" only, this property sets the multi-insert batch size for add requests on thisdataSource
.For dataSources ofserverType
"sql" only, this property sets the multi-insert "non matching" strategy for add requests on thisdataSource
.For dataSources ofserverType
"sql" only, this property sets the multi-insert strategy for add requests on thisdataSource
.boolean
When true, indicates that fields in this DataSource will never be positively updated to the null value; they may arrive at null values by being omitted, but we will not send actual null values in update requests.boolean
IfnoNullUpdates
is set, the value to use for any boolean field that has a null value assigned on an update operation, and does not specify an explicitnullReplacementValue
.IfnoNullUpdates
is set, the value to use for any date or time field that has a null value assigned on an update operation, and does not specify an explicitnullReplacementValue
.float
IfnoNullUpdates
is set, the value to use for any float field that has a null value assigned on an update operation, and does not specify an explicitnullReplacementValue
.int
IfnoNullUpdates
is set, the value to use for any integer field that has a null value assigned on an update operation, and does not specify an explicitnullReplacementValue
.IfnoNullUpdates
is set, the value to use for any text field that has a null value assigned on an update operation, and does not specify an explicitnullReplacementValue
.boolean
When true, andnoNullUpdates
is also true, indicates that "add" requests on this DataSource will have null-valued fields removed from the request entirely before it is sent to the server, as opposed to the default behavior of replacing such null values with defaults.Optional array of OperationBindings, which provide instructions to the DataSource about how each DSOperation is to be performed.Requires that the currently authenticated user match the contents of this field, for client-initiated requests (i.e., whereDSRequest.isClientRequest()
returns true on the server).IfownerIdField
is in force, specifies the access that is allowed to records with a nullownerIdField
.IfownerIdField
is in force, specifies a role that will allow theownerIdField
to take a null value.Applies to RestConnector dataSources (serverType
"rest") only, and is overridable per operationBinding (seeOperationBinding.params
).User-visible plural name for this DataSource.If set, the DataSource will ensure that it never uses a cached HTTP response, even if the server marks the response as cacheable.If true, causes Smart GWT Server to use the "progressive loading" pattern for fetches on this dataSource, as described in the Paging and total dataset length section of theResultSet documentation
.int
Indicates the dataset size that will cause Smart GWT Server to automatically switch intoprogressive loading mode
for this DataSource.For DataSources with type
, looks up the locations to use asprojectFile
projectFileLocations
from the project's configuration (i.e.String[]
For DataSources with type
, specifies locations for the project files.projectFile
For dataSources ofserverType
"sql", determines whether we qualify column names with table names in any SQL we generate.If set, tells the SQL engine to quote column names in all generated DML and DDL statements for this dataSource.For SQL DataSources, tells the framework whether to surround the associatedtable name
with quotation marks whenever it appears in generated queries.Provides a default value forOperationBinding.recordName
.For aSQL DataSource
that is referred byadditional foreign keys
, this property defines the table alias name to use in generated SQL.For aRestConnector DataSource
, the request format to use when contacting the remote REST service.int
Applies toSQL DataSources
only.Additional properties to pass through to theDSRequest
s made by this DataSource.Applies toRestConnector dataSources
(serverType
"rest") only, and is overridable per operationBinding (seeOperationBinding.requestTemplate
).Indicates that the specifiedVelocityExpression
must evaluate to true for a user to access this DataSource.Whether a user must be authenticated in order to access this DataSource.Applies to RestConnector dataSources (serverType
"rest") only, and is overridable per operationBinding (seeOperationBinding.requiresCompleteRESTResponse
).Similar toOperationBinding.requiresRole
, but controls access to the DataSource as a whole.For aRestConnector DataSource
, the response format to use.Applies to RestConnector dataSources (serverType
"rest") only, and is overridable per operationBinding (seeOperationBinding.responseTemplate
).int
Very advanced: for servers that do not support paging, and must return large numbers of XML records in one HTTP response, Smart GWT breaks up the processing of the response in order to avoid the "script running slowly" dialog appearing for an end user.Class for ResultSets used by this datasource.Class for ResultTrees used by this datasource.This property only applies to the built-in SQL DataSource provided in Pro and better editions of Smart GWTFor DataSources that specifyautoDeriveSchema
, this property indicates the name of the Spring bean, Hibernate mapping or fully-qualified Java class to use as parent schema.For a DataSource derived from WSDL or XML schema, the XML namespace this schema belongs to.Default scriptlet to be executed on the server for each operation.Analogous todropExtraFields
, for data sent to the server.For fields oftype
"sequence" in a dataSource ofserverType
"sql", indicates theSequenceMode
to use.Configuration settings that will be used purely on the the server-side.This property allows you to write and use custom DataSource subclasses on the server, by specifying either the fully-qualified name of the DataSource subclass that should be instantiated server-side for this dataSource, or the token "spring:" followed by a valid Spring bean ID, if you wish to instantiate your custom dataSource object using Spring dependency injection.For Direct Method Invocation (DMI) binding, declares the ServerObject to use as the default target for alloperationBindings
.Setting a DataSource to beserverOnly="true"
ensures that it will not be visible to the client.For a DataSource stored in .xml format on the Smart GWT server, indicates what server-side connector to use to execute requests, that is, what happens if you call dsRequest.execute() in server code.For an XML DataSource, URN of the WebService to use to invoke operations.For a DataSource that inheritsfields
from another DataSource (viainheritsFrom
), indicates that only the fields listed in this DataSource should be shown.Whether RPCRequests sent by this DataSource should enableRPCRequest.showPrompt
in order to block user interactions until the request completes.boolean
When true, indicates that any updates for this DataSource include only those fields that have actually changed (and primaryKey fields); when false (the default), all field values are included in updates, whether they have changed or notThe paging strategy to use for this DataSource.If explicitly set true or left null, causes the server to use a "hint" in the SQL we generate for paged queries.If set to true, both client and server-side advanced filtering used by Smart GWT will follow SQL99 behavior for dealing with NULL values, which is often counter-intuitive to users.Applies to RestConnector dataSources (serverType
"rest") only, and is overridable per operationBinding (seeOperationBinding.requestTemplate
).Only applicable to the built-in SQL DataSourceFor DataSources using theSmart GWT SQL engine
for persistence, what database table name to use.Tag name to use when serializing to XML.The special token to look for when trying to resolve template references when thetemplate references mode
is "configOnly
".User-visible name for this DataSource.Best field to use for a user-visible title for an individual record from this dataSource.If set to "false", transformation of values formultiple:true
fields, normally controlled byDataSourceField.multipleStorage
, is instead disabled for this entire DataSource.Applicable toserver-side REST DataSources
onlyA scriptlet to be executed on the server prior to running any operation on this dataSource.A scriptlet to be executed on the server after running any operation on this dataSource.For this dataSource, should the millisecond portion of time and datetime values be trimmed off before before being sent from client to server or vice versa.Only applicable to "union" dataSources, this is a comma-separated list of the names of the dataSource fields that make up the union.Only applicable to "union" dataSources, this is a comma-separated list of the names of the member dataSources that make up the union.For DataSources using theSmart GWT SQL engine
for persistence, whether to use ANSI-style joins (ie, joins implemented with JOIN directives in the table clause, as opposed to additional join expressions in the where clause).LikeDataBoundComponent.useFlatFields
, but applies to all DataBound components that bind to this DataSource.Whether to attempt validation on the client at all for this DataSource.Whether we store server responses for this DataSource intobrowser-based offline storage
, and then use those stored responses at a later time if we are offline (ie, the application cannot connect to the server).For a DataSource that inheritsfields
from another DataSource (viainheritsFrom
), indicates that the parent's field order should be used instead of the order of the fields as declared in this DataSource.For a DataSource withserverType:"sql"
, this flag indicates whether any fields oftype
"sequence" should be backed by a native database sequence (if the flag is true) or an auto-increment/identity column (if it is false).This flag is part of the Automatic Transactions feature; it is only applicable in Power Edition and above.This property is only applicable toSQL
DataSources, and only foroperations
that express acustomSQL
clause.Applies to RestConnector dataSources (serverType
"rest") only, and is overridable per operationBinding (seeOperationBinding.wrapInList
).Sets the XML namespace prefixes available for XPaths on a DataSource-wide basied.Applies to RestConnector dataSources (serverType
"rest") only, and is overridable per operationBinding (seeOperationBinding.xmlTag
). -
Constructor Summary
-
Method Summary
-
Field Details
-
canAggregate
By default, all DataSources are assumed to be capable of handlingServerSummaries
on fetch or filter type operations. This property may be set tofalse
to indicate that this dataSource does not support serverSummaries.NOTE: If you specify this property in a DataSource descriptor (
.ds.xml
file), it is enforced on the server. This means that if you run a request containing serverSummaries against a DataSource that advertises itself ascanAggregate:false
, it will be rejected.Default value is null
- See Also:
-
sqlUsePagingHint
If explicitly set true or left null, causes the server to use a "hint" in the SQL we generate for paged queries. If explicitly set false, forces off the use of hints. This property can be overridden per operationBinding - seeOperationBinding.sqlUsePagingHint
.Note this property is only applicable to
SQL
DataSources, only when apaging strategy
of "sqlLimit" is in force, and it only has an effect for those specific database products where we employ a native hint in the generated SQL in an attempt to improve performance.Default value is null
- See Also:
-
suppressAutoMappings
Applies to RestConnector dataSources (serverType
"rest") only, and is overridable per operationBinding (seeOperationBinding.requestTemplate
).By default, if you have a
requestFormat
of "params",RestConnector
will add your values or criteria as standard HTTP parameters to the the URL it generates for hitting the target REST server - this is described in more detail in theRESTRequestFormat
documentation.With a
requestFormat
of "json",RestConnector
will generate a block of JSON from your criteria or values, again as described in theRESTRequestFormat
docsYou can switch off both of these behaviors by setting this property true
Default value is false
- See Also:
-
resultBatchSize
public int resultBatchSizeVery advanced: for servers that do not support paging, and must return large numbers of XML records in one HTTP response, Smart GWT breaks up the processing of the response in order to avoid the "script running slowly" dialog appearing for an end user.If you have a relatively small number of records with a great deal of properties or subobjects on each record, and you have not set
dropExtraFields
to eliminate unused data, and you see the "script running slowly" dialog, you may need to set this number lower.Default value is 150
-
beanClassName
This property has different meanings depending on theserverType
:For SQL DataSources (DataSources with serverType "sql")
If set, results from the database will be used to create one instance of the indicated Java bean per database row. Otherwise a Map is used to represent each row retrieved from SQL.With this feature active, a DSResponse from this DataSource will contain a Collection of instances of the indicated
beanClassName
, available via DSResponse.getData(). This creates a couple of possibilities:- Add business logic for derived properties, such as computed formulas
- For example, declare a DataSourceField named "revenueProjection". By default this field will call getRevenueProjection() on your bean to retrieve the value to send to the client. Your implementation of getRevenueProjection() could apply some kind of formula to other values loaded from the database.
- Call business logic on retrieved beans via DMI
- By
adding a
DMI
method that calls DSRequest.execute() to retrieve a DSResponse, you have an opportunity to call business logic methods on the beans representing each row affected by the DSRequest. For example, notify a related BPEL process of changes to certain fields.
By using
beanClassName
on a specificOperationBinding
, you can:- Use a bean to represent your data only when it matters; for example, avoid the overhead of using a bean for "fetch" operations, but do use a bean for "update" operations so that you can execute relevant business logic after the update completes.
- Skip the use of beans for complex reporting queries that produce results unrelated to your persistent object model. Set beanClassName to blank ("") on a specific operationBinding to override DataSource.beanClassName for that specific operation.
- For SQL joins that produce additional data fields, use a special, operation-specific bean that represents a join of multiple entities and contains business logic specific to that joined dataset
Note that
beanClassName
affects what numeric field types will be used for inbound DSRequest data. For fields with numeric types, therecord data
in DSRequests will automatically be converted to the type of the target field, before the request is received in a DMI. For details, seeDsRequestBeanTypes
.Note that
DMI
also has a built-in facility for populating a bean with the inboundDSRequest.data
- just declare the bean as a method argument.For generic DataSources (DataSources with serverType "generic")
Reify
sets this property when it creates a generic DataSource using the Javabean Wizard. It has no built-in server-side effects.For Hibernate DataSources (DataSources with serverType "hibernate")
The name of the Java bean or POJO class that is mapped in Hibernate. This will typically be the fully-qualified class name - egcom.foo.MyClass
- but it may be the simple class name - justMyClass
- or it may be some other value. It all depends on how your classes have been mapped in Hibernate.The declared Java bean will affect how its properties will be mapped to built-in numeric types, see
Hibernate Integration overview
for details.Note: If you are intending to use Hibernate as a data-access layer only, you do not need to create Hibernate mappings or Java objects: Smart GWT will generate everything it needs on the fly.
For JPA DataSources (DataSources with serverType "jpa" or "jpa1")
The fully qualified class name of the JPA annotated entity.NOTE for Hibernate and JPA users: When you use JPA, or use Hibernate as a full ORM system (ie, not just allowing Smart GWT Server to drive Hibernate as a data access layer), the beans returned on the server-side are live. This means that if you make any changes to them, the ORM system will persist those changes. This is true even if the beans were created as part of a fetch operation.
This causes a problem in the common case where you want to use a DMI or custom DataSource implementation to apply some post-processing to the beans fetched from the persistent store. If you change the values in the beans directly, those changes will be persisted.
If you want to alter the data returned from a JPA or Hibernate persistent store as part of a fetch request just so you can alter what gets sent to the client, you can use the server-side
DSResponse
'sgetRecords()
method. This will return your bean data in "record" format - ie, as a List of Maps. You can alter these records without affecting your persistent store, and then callsetData()
on theDSResponse
), passing the altered list of records. See the server-side Javadocs forDSResponse
for details of these two methods.Default value is null
- See Also:
-
auditDataSourceID
For DataSources withauditing enabled
, optionally specifies the ID of the audit DataSource. If this property is not specified, the ID of the audit DataSource will beaudit_[OriginalDSID]
Default value is null
-
serverConstructor
This property allows you to write and use custom DataSource subclasses on the server, by specifying either- the fully-qualified name of the DataSource subclass that should be instantiated server-side for this dataSource, or
- the token "spring:" followed by a
valid Spring bean ID, if you wish to instantiate your custom dataSource object using Spring
dependency injection. For example,
"spring:MyDataSourceBean"
. See alsoServerInit
for special concerns with framework initialization when using Spring. It is also particularly important that you read the discussion of caching and thread-safety linked to below, as there are special considerations in this area when using Spring. - the token "cdi:" followed by a valid CDI bean name, if you wish to instantiate
your custom dataSource object using CDI dependency injection. For example,
"cdi:MyDataSourceBean"
.
One reason you might wish to do this would be to override the validate() method to provide some arbitrary custom validation (such as complex database lookups, validation embedded in legacy applications, etc). It is also possible - though obviously a more substantial task - to override the execute() method in your custom DataSource. This is one way of creating a completely customized DataSource implementation.
Note: If you use this property, you are responsible for making sure that it refers to a valid server-side class that extends
com.isomorphic.datasource.BasicDataSource
, or to a Spring bean of the same description. If your implementation relies on methods or state only present in certain specialized subclasses of DataSource (for example, you want the normal behavior and features of a HibernateDataSource, but with a specialized validate() method), then you should extend the subclass rather than the base class.NOTE: Please take note of the points made in
this discussion
of caching and thread-safety issues in server-side DataSources.Default value is null
-
dataFormat
Indicates the format to be used for HTTP requests and responses when fulfilling DSRequests (eg, whenfetchData()
is called).Default value is "iscServer"
- See Also:
-
jsonSuffix
Allows you to specify an arbitrary suffix string to apply to all json format responses sent from the server to this application.The inclusion of such a suffix ensures your code is not directly executable outside of your application, as a preventative measure against javascript hijacking.
Only applies to responses formatted as json objects. Does not apply to responses returned via scriptInclude type transport.
Default value is null
-
sequenceMode
For fields oftype
"sequence" in a dataSource ofserverType
"sql", indicates theSequenceMode
to use. This property has no effect for fields or dataSources of other types.You can set a default sequenceMode for all DataSources of a given database type by setting property "sql.{database_type}.default.sequence.mode" in
server.properties
. You set a global default sequenceMode that applies to all database types by setting property "sql.default.sequence.mode". For example:sql.mysql.default.sequence.mode: jdbcDriver
Default value is "native"
-
sqlPaging
The paging strategy to use for this DataSource. If this property is not set, the default paging strategy, specified with theserver.properties
settingsql.defaultPaging
, is used.This setting can be overridden with the
OperationBinding.sqlPaging
property.NOTE: Operations that involve a
customSQL
clause ignore this property, because customSQL operations usually need to be treated as special cases. For these operations, the paging strategy comes from theserver.properties
settingsql.defaultCustomSQLPaging
orsql.defaultCustomSQLProgressivePaging
, depending on whether or notprogressiveLoading
is in force. Note that these can always be overridden by asqlPaging
setting on the OperationBinding.Default value is null
- See Also:
-
script
Default scriptlet to be executed on the server for each operation. IfOperationBinding.script
is specified, it will be executed for the operation binding in question instead of running this scriptlet.Scriptlets are used similarly to DMIs configured via
serverObject
orOperationBinding.serverObject
- they can add business logic by modifying the DSRequest before it's executed, modifying the default DSResponse, or taking other, unrelated actions.For example:
<DataSource> <script language="groovy"> ... Groovy code ... </script> ... other DataSource properties </DataSource>
Scriptlets can be written in any language supported by the "JSR 223" standard, including Java itself. See the
DMI Script Overview
for rules on how to return data, add additional imports, and other settings.The following variables are available for DMI scriptlets:
- requestContext: RequestContext (from com.isomorphic.servlet)
- dataSource: the current DataSource (same as DSRequest.getDataSource())
- dsRequest: the current DSRequest
- criteria: shortcut to DSRequest.getCriteria() (a Map)
- values: shortcut to DSRequest.getValues() (a Map)
- oldValues: shortcut to DSRequest.getOldValues() (a Map)
- log: an instance of
com.isomorphic.log.Logger
, so your scripts can log in the same manner as regular Java code - config: an instance of
com.isomorphic.base.Config
, so your scripts have access to yourserver.properties
settings - sqlConnection: SQLDataSource only: the current SQLConnection object. If
using
automatic transactions
are enabled, this SQLConnection is in the context of the current transaction - rpcManager: the current RPCManager
- applicationContext: the Spring ApplicationContext (when applicable)
- beanFactory: the Spring BeanFactory (when applicable)
Scriptlets also have access to a set of contextual variables related to the Servlets API, as follows:
- servletRequest: the current ServletRequest
- session: the current HttpSession
- servletResponse: the current ServletResponse (advanced use only)
- servletContext: the current ServletContext(advanced use only)
HttpSession
prevents your DataSource from being used in a command-line process.Note that if a dataSource configuration has both a
<script>
block and a specifiedserverObject
for some operation, the script block will be executed, and the serverObject ignored.Default value is null
-
fileNameField
The native field name used by this DataSource on the server to represent thefileName
forFileSource Operations
operations. Any extensions to the fileName to indicate type or format (e.g. ".ds.xml") are stored in thefileTypeField
andfileFormatField
, if specified for this DataSource.If not specified for a DataSource, the fileNameField will be inferred on the server as follows:
- If there is a field named "fileName", "name", or "title", then that field is used.
- Otherwise, if there is a single primary key, and it has the type "text", then that field is used.
- Otherwise, an error is logged
Default value is null
- See Also:
-
autoJoinTransactions
If true, causes all operations on this DataSource to automatically start or join a transaction associated with the current HttpServletRequest. This means that multiple operations sent to the server in arequest queue
will be committed in a single transaction.Note that this includes fetch operations - setting this property to true has the same effect as a transaction policy of ALL for just this DataSource's operations - see the server-side
RPCManager.setTransactionPolicy()
for details of the different TransactionPolicy settings.If this property is explicitly false, this causes all operations on this DataSource to be committed individually - the same as a transaction policy of NONE, just for this DataSource's operations.
In either case, you can override the setting for individual operations - see
OperationBinding.autoJoinTransactions
.If this property if null or not defined, we fall back to the default setting for this type of DataSource. These are defined in
server.properties
as follows:- Hibernate:
hibernate.autoJoinTransactions
- JPA/JPA2:
jpa.autoJoinTransactions
- SQL: There is one
setting per configured database connection (
dbName
). For example, the setting for the default MySQL connection issql.Mysql.autoJoinTransactions
server.properties
asautoJoinTransactions
.At the dbName and global system levels, you can set the autoJoinTransactions attribute to a valid Transaction Policy, rather than a simple true or false (although these values work too - true is the same as ALL, false is the same as NONE). For valid TransactionPolicy values and their meanings, see the server-side Javadoc for
RPCManager.setTransactionPolicy()
Note that the configuration settings discussed here can be overridden for a particular queue of requests by setting the server-side RPCManager's transaction policy. Look in the server-side Javadoc for
RPCManager.getTransactionPolicy()
.Transactions can also be initiated manually, separate from the RPCManager/HttpServletRequest lifecycle, useful for both multi-threaded web applications, and standalone applications that don't use a servlet container - see
StandaloneDataSourceUsage
.NOTE: Setting this property to true does not cause a transactional persistence mechanism to automatically appear - you have to ensure that your DataSource supports transactions. The Smart GWT built-in SQL, Hibernate and JPA DataSources support transactions, but note that they do so at the provider level. This means that you can combine updates to, say, an Oracle database and a MySQL database in the same queue, but they will be committed in two transactions - one per database. The Smart GWT server will commit or rollback these two transactions as if they were one, so a failure in some Oracle update would cause all the updates to both databases to be rolled back. However, this is not a true atomic transaction; it is possible for one transaction to be committed whilst the other is not - in the case of hardware failure, for example.
NOTE: Not all the supported SQL databases are supported for transactions. Databases supported in this release are:
- DB2
- HSQLDB
- Firebird
- Informix
- Microsoft SQL Server
- MySQL (you must use InnoDB tables; the default MyISAM storage engine does not support transactions)
- MariaDB
- Oracle
- PostgreSQL
Default value is null
- See Also:
- Hibernate:
-
auditUserFieldName
For DataSources withauditing enabled
, specifies the field name used to store the user who performed the operation. If empty string is specified as the field name, the audit DataSource will not store this field.Default value is "audit_modifier"
-
operationBindings
Optional array of OperationBindings, which provide instructions to the DataSource about how each DSOperation is to be performed.When using the Smart GWT Server, OperationBindings are specified in your DataSource descriptor (.ds.xml file) and control server-side behavior such as what Java object to route DSRequest to (
OperationBinding.serverObject
) or customizations to SQL, JQL and HQL queries (OperationBinding.customSQL
,OperationBinding.customJQL
andOperationBinding.customHQL
). See the @see Java Integration samples.For DataSources bound to WSDL-described web services using
serviceNamespace
, OperationBindings are used to bind each DataSourceoperationType
to anoperation
of a WSDL-describedweb service
, so that a DataSource can both fetch and save data to a web service.For example, this code accomplishes part of the binding to the SalesForce partner web services
DataSource dataSource = new DataSource(); dataSource.setServiceNamespace("urn:partner.soap.sforce.com"); OperationBinding fetch = new OperationBinding(); fetch.setOperationType(DSOperationType.FETCH); fetch.setWsOperation("query"); fetch.setRecordName("sObject"); OperationBinding add = new OperationBinding(); add.setOperationType(DSOperationType.ADD); add.setWsOperation("create"); add.setRecordName("SaveResult"); OperationBinding update = new OperationBinding(); update.setOperationType(DSOperationType.UPDATE); update.setWsOperation("update"); update.setRecordName("SaveResult"); OperationBinding remove = new OperationBinding(); remove.setOperationType(DSOperationType.REMOVE); remove.setWsOperation("delete"); remove.setRecordName("DeleteResult"); dataSource.setOperationBindings(fetch, add, update, remove);
NOTE: additional code is required to handle authentication and other details, see the complete code in smartclientSDK/examples/databinding/SalesForce.For DataSources that contact non-WSDL-described XML or JSON services, OperationBindings can be used to separately configure the URL, HTTP method, input and output processing for each operationType. This makes it possible to fetch JSON data from one URL for the "fetch" operationType and save to a web service for the "update" operationType, while appearing as a single integrated DataSource to a
DataBoundComponent
such as aneditable ListGrid
.If no operationBinding is defined for a given DataSource operation, all of the properties which are valid on the operationBinding are checked for on the DataSource itself.
This also means that for a read-only DataSource, that is, a DataSource only capable of fetch operations, operationBindings need not be specified, and instead all operationBinding properties can be set on the DataSource itself. In the RSS Feed sample, you can see an example of using OperationBinding properties directly on the DataSource in order to read an RSS feed.
Default value is null
- See Also:
-
logSlowRemove
Allows you to specify"remove" operation
SQL query execution time threshold in milliseconds, which if exceeded query is identified as "slow" and may be logged under specific logging category.See
logSlowSQL
for more details.Default value is null
-
fileTypeField
The native field name used by this DataSource on the server to represent thefileType
forFileSource Operations
.If the fileTypeField is not configured, then a field named "fileType" will be used, if it exists. Otherwise, the DataSource will not track fileTypes -- this may be acceptable if, for instance, you use a separate DataSource for each fileType.
The fileType is specified according to the extension that would have been used in the filesystem -- for instance, the fileType for employees.ds.xml would be "ds".
Default value is null
- See Also:
-
useFlatFields
LikeDataBoundComponent.useFlatFields
, but applies to all DataBound components that bind to this DataSource.Default value is null
-
infoField
Name of the field that has the second most pertinent piece of textual information in the record, for use when aDataBoundComponent
needs to show a short summary of a record.For example, for a DataSource of employees, a "job title" field would probably be the second most pertinent text field aside from the employee's "full name".
Unlike
titleField
, infoField is not automatically determined in the absence of an explicit setting.Default value is null
-
xmlNamespaces
Sets the XML namespace prefixes available for XPaths on a DataSource-wide basied. SeeOperationBinding.xmlNamespaces
for details.Default value is See below
- See Also:
-
multiInsertNonMatchingStrategy
For dataSources ofserverType
"sql" only, this property sets the multi-insert "non matching" strategy for add requests on thisdataSource
. Only has an effect if theadd request
specifies a list of records as the data, and only ifmultiInsertStrategy
is set to "multipleValues" either globally or at theDSRequest
,OperationBinding
, orDataSource
level. See the docs forMultiInsertNonMatchingStrategy
for more information.Note that this setting (along with the other multi-insert properties,
multiInsertStrategy
andmultiInsertBatchSize
) can be overridden at theoperationBinding level
and thedsRequest level
. If you wish to configure multi-insert setting globally, see the documentation formultiInsertStrategy
.Default value is "padWithNulls"
- See Also:
-
requires
Indicates that the specifiedVelocityExpression
must evaluate to true for a user to access this DataSource.See also
OperationBinding.requires
.Default value is null
- See Also:
-
ID
Unique identifier for this DataSource. Required for all DataSources.Default value is null
-
maxFileVersions
Ifautomatic file versioning
is enabled for a FileSource DataSource, this property configures the maximum number of versions to retain.Default value is 20
- See Also:
-
allowDynamicTreeJoins
By default, custom dataSource implementations are assumed to be unable to supportdynamic tree joins
. If you create a custom dataSource that can support such joins, set this flag to trueDefault value is null
-
tagName
Tag name to use when serializing to XML. If unspecified, thedataSource.ID
will be used.Default value is null
- See Also:
-
generateAuditDS
public boolean generateAuditDSFor anaudited
DataSource, controls whether the Framework will attempt to auto-generate the audit DataSource. Note that this property is independent ofauditDataSourceID
so that, by default, even when the audit DataSource is given a non-default ID, the Framework will still attempt to auto-generate it.Default value is true
-
allowClientRequestedSummaries
If aDSRequest
arrives from the client that requestsserver-calculated summaries
, should it be allowed?Note this setting only affects
dsRequests
that come from the browser (or another client). This setting has no effect on server summaries declared in .ds.xml files or summaries configured in DSRequests created programmatically on the server side, which are always allowed.Default value of null means this DataSource will use the system-wide default, which is set via
datasources.allowClientRequestedSummaries
inserver.properties
, and defaults to allowing client-requested summaries.If client-requested summarization is allowed, but the server-side <operationBinding> provides specific summarization settings, the client-requested summarization is ignored.
Default value is null
-
responseTemplate
Applies to RestConnector dataSources (serverType
"rest") only, and is overridable per operationBinding (seeOperationBinding.responseTemplate
).If you have a
responseFormat
of "json" or "xml", this property allows you to specify a template forRestConnector
to use in order to construct response data for the client, from the response data sent by the REST server. This allows you to use the full power of the Velocity Templating Language to perform mappings and other transformations, all declaratively. The process involves the following steps:- We parse the REST response text as either JSON or XML, depending on the
responseFormat
- If a
record-level XPath
is declared, it is applied to the parsed REST response data - We parse the template as JSON and convert it into an internal object structure
- Velocity templating is now performed on this structure, with the processed REST response data provided as context variables. Templates intended for use with multi-record datasets should be framed in terms of a single record - if the REST response data consists of multiple records, each record will be put through the template in turn
- If the original request came from a remote client (eg, a browser-based UI), the same
downstream serialization logic as used for all other DataSource types will serialize this
processed structure in accordance with the
client-server dataFormat
in use; this is completely separate from theresponseFormat
used to process the response from the REST server
responseTemplate
, it serves as the basis for the entire JSON or XML structure sent back the client, so you can include, omit, rename or transform values from the client request as required.Example template
Consider a case where the REST server sends back this structure:{ "ID": 1234, "FOO": 27, "BAR": "TRUE", "ABC": "String Value" }
Or, equivalently for aresponseFormat
of XML (note, this would also require arecordXPath
of "/ITEM" to navigate to the subvalues):<?xml version="1.0" encoding="UTF-8"?> <ITEM> <ID>1234</ID> <FOO>27</FOO> <BAR>TRUE</BAR> <ABC>String value</ABC> </ITEM>
You need to transform this into the record format required by your local dataSource, which looks like this:{ id: 1234, // ID from the REST response zoo: 27, // FOO from the REST response baz: true, // BAR from the REST response def: "String value" // abc from the REST response isTBD: false // should be true if "def" == "TBD", otherwise false }
The following template would declaratively handle the necessary mappings from one format to the other:<responseTemplate> { id: $restResponseData.ID, zoo: $restResponseData.FOO, baz: #if($restResponseData.BAR == "TRUE") true #else false #end, def: "$restResponseData.ABC", isTBD: #if($restResponseData.ABC == "TBD") true #else false #end } </responseTemplate>
Logically, it makes sense to express the template in JSON: XML is only the format of the data sent back by the remote REST server; by the time we come to apply the template, that XML has already been parsed into an internal memory structure based on Java Lists and Maps, and JSON is the simplest text-based analog of that data structure.However, if you have a
requestFormat
of "xml", you will be expressing yourrequestTemplate
in XML; again, this makes sense because therequestTemplate
is a representation of the actual text we are going to send to the remote REST server, whereas theresponseTemplate
is not a direct representation of anything (post-templating, it will be serialized in the format that the client requires, which unrelated to the format required by the remote REST server).Even though this difference makes sense, it may seem confusing or inconsistent to express the
requestTemplate
as XML and theresponseTemplate
as JSON, so whenrequestFormat
is "xml", we support expressing theresponseTemplate
in either JSON or XML. So if you prefer, you could write this template in XML:<responseTemplate><![CDATA[ <ITEM> <id>$restResponseData.ID<is/id> <zoo>$restResponseData.FOO</zoo> <baz>#if($restResponseData.BAR == "TRUE") true #else false #end</baz> <def>$restResponseData.ABC</def> <isTBD>#if($restResponseData.ABC == "TBD") true #else false #end<isTBD> </ITEM> ]]></responseTemplate>
See the Velocity User Guide for full details of Velocity's templating featuresDefault value is null
- We parse the REST response text as either JSON or XML, depending on the
-
useLocalValidators
Whether to attempt validation on the client at all for this DataSource. If unset (the default), client-side validation is enabled.Disabling client-side validation entirely is a good way to test server-side validation.
Default value is null
- See Also:
-
enumTranslateStrategy
Sets the strategy this DataSource uses to translate Java enumerated types (objects of type enum) to and from Javascript. This property is only applicable if you are using the Smart GWT serverDefault value is null
-
clientOnly
A clientOnly DataSource simulates the behavior of a remote data store by manipulating a static dataset in memory asDSRequests
are executed on it. Any changes are lost when the user reloads the page or navigates away.A clientOnly DataSource will return responses asynchronously, just as a DataSource accessing remote data does. This allows a clientOnly DataSource to be used as a temporary placeholder while a real DataSource is being implemented - if a clientOnly DataSource is replaced by a DataSource that accesses a remote data store, UI code for components that used the clientOnly DataSource will not need be changed.
A clientOnly DataSource can also be used as a shared cache of modifiable data across multiple UI components when immediate saving is not desirable. In this case, several components may interact with a clientOnly DataSource and get the benefit of
ResultSet
behaviors such as automatic cache sync and in-browser data filtering and sorting. When it's finally time to save,cacheData
can be inspected for changes and data can be saved to the original DataSource viaaddData()
,updateData()
andremoveData()
, possibly in atransactional queue
. Note thatgetClientOnlyDataSource()
lets you easily obtain aclientOnly
DataSource representing a subset of the data available from a normal DataSource.See also
cacheAllData
- acacheAllData
behaves like a write-through cache, performing fetch and filter operations locally while still performing remote save operations immediately.ClientOnly DataSources can be populated programmatically via
cacheData
- seethis discussion
for other ways to populate a client-only DataSource with data.Default value is false
- See Also:
-
ignoreTextMatchStyleCaseSensitive
For fields on this dataSource that specifyignoreTextMatchStyle
true, the prevailing textMatchStyle is ignored and Smart GWT matches exact values. This property dictates whether that match is case-sensitive like the "exactCase" textMatchStyle, or case-insensitive like the "exact" textMatchStyle (the default). Please see theTextMatchStyle documentation
for a discussion of the nuances of case-sensitive matching.Default value is false
-
responseFormat
For aRestConnector DataSource
, the response format to use. Can be overridden at operationBinding level, seeOperationBinding.responseFormat
Note, ifresponseFormat
is not specified at either the DataSource or OperationBinding level, response processing will throw an exception.Default value is null
- See Also:
-
criteriaPolicy
Decides under what conditions theResultSet
cache should be dropped when theResultSet.criteria
changes.Default value is "dropOnShortening"
-
requestTemplate
Applies toRestConnector dataSources
(serverType
"rest") only, and is overridable per operationBinding (seeOperationBinding.requestTemplate
).If you have a
requestFormat
of "json" or "xml",RestConnector
will generate a block of JSON or XML, as appropriate, from your criteria or values, as described in theRESTRequestFormat
docs. You can also specify arequestTemplate
, andRestConnector
will use the template to drive the generation of the JSON or XML, so you can use the full power of the Velocity Templating Language to perform mappings and other transformations, all declaratively. The process involves the following steps:- We parse the template as JSON or XML, as appropriate, and convert it into an internal object structure
- Velocity templating is now performed on this structure, with the
DSRequest
values and criteria as context variables - We serialize the result of this process back to JSON or XML
requestTemplate
, it serves as the basis for the entire JSON or XML structure sent to the REST server, so you can include, omit, rename or transform values from the client request as required. Also note, if thedsRequest
has multiple valueSets (records), we will apply the template to each valueSet in turn, to construct a list for sending to the remote REST service (but note, this only works if therequestFormat
is "json").Example templates
Templates can make use of all of the conditional and iteration features of the Velocity Template Language, so can be used to perform some fairly sophisticated transformations. Consider a case where we have an update request with data like this sent from the client:{ pk: 1234, foo: 27, bar: true, abc: "String Value" }
This record contains all the information you need to send an update request to the remote REST server, but that server requires things in a different format, with different field names, different representations of boolean values, and an additional field whose value is derived. This record looks like this:{ id: 1234, // pk from our client record FOO: 27, // foo from our client record BAR: 1, // bar from our client record, true == 1, false == 0 def: "String value" // abc from our client record isTBD: 0 // should be 1 if "def" == "TBD", otherwise 0 }
The following template would declaratively handle the necessary mappings from one format to the other:<requestTemplate> { "id": $values.pk, "FOO": $values.foo, "BAR": #if($values.bar) 1 #else 0 #end, "def": "$values.abc", "isTBD": #if($values.abc == "TBD") 1 #else 0 #end } </requestTemplate>
And the same thing in XML (this may require setting anxmlTag
and/or providing additional levels of containment to match the target server's structure - XML often requires more boilerplate than JSON):<requestTemplate> <record> <id>$values.pk</id> <FOO>$values.foo</FOO> <BAR>#if($values.bar)1#else0#end</BAR> <def>$values.abc</def> <isTBD>#if($values.abc == "TBD")1#else0#end</isTBD> </record> </requestTemplate>
Templates can also be used to flatten structured data. Say we have this incoming record:{ customerId: 2770 name: "Snape Networks Inc", contacts: [ {name: "Isaura Lopez", title: "IT Manager"}, {name: "Ngozi Okoduwa", title: "VP Procurement"}, {name: "Andrew Jenkins", title: "Buyer"} ] }
The target REST server does not support a list of contact details, just two contact names:{ Id: 2770, Name: "Snape Networks Inc", Contact1: "Isaura Lopez", Contact2: "Ngozi Okoduwa" }
This transformation could be achieved with the following template:<requestTemplate> { Id: $values.customerId, Name: "$values.name", #foreach ($contact in $values.contacts) #if ($foreach.count > 2) #break #end Contact$foreach.count: "$contact.name" #end } </requestTemplate>
See the Velocity User Guide for full details of Velocity's templating featuresDefault value is null
-
logSlowAdd
Allows you to specify"add" operation
SQL query execution time threshold in milliseconds, which if exceeded query is identified as "slow" and may be logged under specific logging category.See
logSlowSQL
for more details.Default value is null
-
callbackParam
Applies only to dataFormat: "json" anddataTransport
:"scriptInclude". Specifies the name of the query parameter that tells your JSON service what function to call as part of the response.Default value is "callback"
-
auditTimeStampFieldName
For DataSources withauditing enabled
, specifies the field name used to store the timestamp when the operation was performed (in a field of type "datetime"). If empty string is specified as the field name, the audit DataSource will not store this field.Default value is "audit_changeTime"
-
mockDataCriteria
WhenmockMode
is enabled, criteria to use in an initial "fetch" DSRequest to retrieve sample data.Default value is null
-
progressiveLoadingThreshold
public int progressiveLoadingThresholdIndicates the dataset size that will cause Smart GWT Server to automatically switch intoprogressive loading mode
for this DataSource. To prevent automatic switching to progressive loading, set this property to -1. This may also be prevented on a per-request basis by settingDSRequest.progressiveLoading
tofalse
.Default value is 200000
-
showLocalFieldsOnly
For a DataSource that inheritsfields
from another DataSource (viainheritsFrom
), indicates that only the fields listed in this DataSource should be shown. All other inherited parent fields will be marked "hidden:true".Default value is null
-
serviceNamespace
For an XML DataSource, URN of the WebService to use to invoke operations. This URN comes from the "targetNamespace" attribute of the <wsdl:definitions> element in a WSDL (Web Service Description Language) document, and serves as the unique identifier of the service.Having loaded a WebService using
XMLTools.loadWSDL()
, settingserviceNamespace
combined with specifyingoperationBindings
that setOperationBinding.wsOperation
will cause a DataSource to invoke web service operations to fulfill DataSource requests (DSRequests
).Setting
serviceNamespace
also defaultsdataURL
to the service's location,dataFormat
to "xml" anddataProtocol
to "soap".Default value is null
- See Also:
-
fileVersionField
The native field name used by this DataSource on the server to representfileVersion
forFileSource Operations
.Automatic file versioning is configured by the presence of this property: if you want automatic versioning for a FileSource DataSource, it is sufficient to simply define a
fileVersionField
. When automatic versioning is on:- Calls to
saveFile()
will save a new version of the file, retaining previous versions up to the maximum configured bymaxFileVersions
; when that maximum is reached, the oldest version is overwritten - The
getFile()
API always returns the most recent version - The
listFiles()
API only includes the most recent version of any file - You can view and retrieve earlier
versions of a file with the
listFileVersions()
andgetFileVersion()
APIs. Note that retrieving a previous version of a file and then callingsaveFile()
goes through the normal process of saving a new version
The
fileVersion
field is expected to be of type "datetime", and automatic versioning will not work otherwise. Note, to minimize the possibility of version timestamp collisions, we recommend thatfileVersion
fields specifystoreMilliseconds
: true.If the fileVersionField is not configured, no automatic file versioning will be done.
Default value is null
- See Also:
-
maxFileVersions
DataSource.listFileVersions(com.smartgwt.client.data.FileSpec, com.smartgwt.client.data.DSCallback)
DataSource.getFileVersion(com.smartgwt.client.data.FileSpec, java.util.Date, com.smartgwt.client.callbacks.GetFileVersionCallback)
DataSource.removeFileVersion(com.smartgwt.client.data.FileSpec, java.util.Date)
FileSource Operations
- Calls to
-
unionFields
Only applicable to "union" dataSources, this is a comma-separated list of the names of the dataSource fields that make up the union. This property is optional; if it is not supplied, Smart GWT Server will derive a list of fields from the member dataSources (seeunionOf
), where name and data type match. SeedefaultUnionFieldsStrategy
for more details.Note, this setting is only useful for fields that are named the same on the member dataSources. For a more flexible and powerful way to define the unioned fields, that does not rely on field names being the same in member dataSources, you can use
field-level unionOf definitions
.Default value is null
-
allowTemplateReferences
Indicates the mode to use for resolving templated references in this DataSource's configuration file. A "templated reference" is a reference that makes use of a special token to indicate it is a placeholder that should be replaced with a value derived from theserver.properties
file - in "all
" mode, other relatively static context available to the Velocity engine can also be used - during DataSource initialization. You can place a templated reference inside any string property, anywhere in your.ds.xml
file.Templated references are a simple, lightweight way to introduce a level of dynamism to DataSource configuration. For example, you could use a templated reference to dynamically set the
dbName
If you need more extensive support for dynamic DataSources than can be provided with templated references, you can completely customize configuration on-the-fly using a Dynamic DataSource Generator - see the server-side API
com.isomorphic.datasource.DataSource.addDynamicDSGenerator()
The default value for this property is generally "
configOnly
" - any DataSource that extendsBasicDataSource
, including the built-in SQL, Hibernate and JPA DataSource implementations, will default to this setting. You can override this across the board by adding a setting like this to yourserver.properties
file:dataSource.default.allowTemplateReferences: none # or dataSource.default.allowTemplateReferences: all
ForRestConnector
DataSources (serverType
s "rest" and "odata"), the default value for this property is "all
", in keeping with that DataSource's extensive support for Velocity templating.Default value is See Below
- See Also:
-
noNullUpdates
public boolean noNullUpdatesWhen true, indicates that fields in this DataSource will never be positively updated to the null value; they may arrive at null values by being omitted, but we will not send actual null values in update requests. When false (the default), null is not treated in any special way.Setting this value causes null-assigned fields to be replaced with the field's
nullReplacementValue
, if one is declared. If nonullReplacementValue
is declared for the field, the null assignment is replaced with the DataSource'snullStringValue
,nullIntegerValue
,nullFloatValue
ornullDateValue
, depending on the field type.For "add" operations, setting
omitNullDefaultsOnAdd
causes null-valued fields to be removed from the request entirely, rather than replaced with default values as described above.Default value is false
-
transformMultipleFields
If set to "false", transformation of values formultiple:true
fields, normally controlled byDataSourceField.multipleStorage
, is instead disabled for this entire DataSource.Default value is null
-
enumConstantProperty
The name of the property this DataSource uses for constant name when translating Java enumerated types to and from Javascript, if theEnumTranslateStrategy
is set to "bean". Defaults to "_constant" if not set.This property is only applicable if you are using the Smart GWT server
Default value is null
-
transformRawResponseScript
Applicable toserver-side REST DataSources
onlyA scriptlet to be executed on the server after data has been fetched from the REST service, but before it is processed through templating. The intention is that this scriptlet transforms the response data in some way, before that transformed data is passed through templating and further downstream transformation steps such as
record transformation
. If your use case does not involve templating, there is no difference between putting your transformation logic in this script, or putting it in atransformResponseScript
- they are merely pre-templating and post-templating transformation opportunities, so if no templating is involved, they are conceptually the same thing. Accordingly, exactly the same variables are available to thetransformRawResponseScript
as to thetransformResponseScript
- see that property's documentation for details.Note, if you prefer a Java solution rather than placing scripts in your
.ds.xml
files, you can instead extend the JavaRestConnector
class and override itstransformRawResponse()
method. If you both override the Java method and provide atransformRawResponseScript
, the Java method runs first and any transformations it makes will be visible to the script. SeeserverConstructor
for details of how to use a custom class to implement a DataSource server-side.Default value is null
-
recordName
Provides a default value forOperationBinding.recordName
.Default value is null
- See Also:
-
clientRequestMaxRows
public int clientRequestMaxRowsApplies toSQL DataSources
only.If this attribute is set to a non-negative value, it acts as a hard safety limit for client-initiated
DSRequest
s for "all rows". If the server encounters more rows in a response than this safety limit, it will abort immediately with an Exception.This attribute is not meant to be a regular application facility. As mentioned above, it is a safety mechanism, intended primarily to prevent bugs in development from causing long delays or server Out Of Memory crashes by unintentionally issuing requests that fetch huge numbers of rows (eg, by failing to specify filter criteria).
Note the following:
- This limit only has an effect when "all rows" are requested - ie, when the request
does not specify an
endRow
, or specifiesendRow:-1
. If you specify a non-negativeendRow
, it will be honored even if that means we need to return more thanclientRequestMaxRows
records - If you need to handle very large datasets in a manageable way, consider using
ProgressiveLoading
to stream the data progressively - Note that this attribute applies to client-initiated requests only. If you want to
provide a hard safety limit for all fetches, including requests initiated on the server,
set a
requestMaxRows
instead. If both properties are specified,clientRequestMaxRows
wins for client-initiated requests, so it is possible to configure different limits for client- and server-initiated requests
To set a default
clientRequestMaxRows
that will apply to all dataSources that do not specify the attribute, add the following to yourserver.properties
file:# Fail with an error if we try to fetch more than 10000 rows in a client request sql.clientRequestMaxRows: 10000
Default value is -1
- See Also:
- This limit only has an effect when "all rows" are requested - ie, when the request
does not specify an
-
dataTransport
Transport to use for all operations on this DataSource. Defaults todefaultTransport
. This would typically only be set to enable "scriptInclude" transport for contactingJSON
web services hosted on servers other than the origin server.When using the "scriptInclude" transport, be sure to set
callbackParam
orOperationBinding.callbackParam
to match the name of the query parameter name expected by your JSON service provider.Default value is RPCManager.defaultTransport
-
dropExtraFields
Indicates that for server responses, for any data being interpreted as DataSource records, only data that corresponds to declared fields should be retained; any extra fields should be discarded.For
JSON
data, this means extra properties in selected objects are dropped.By default, for DMI DSResponses, DSResponse.data is filtered on the server to just the set of fields defined on the DataSource (see the overview in
DMI
).This type of filtering can also be enabled for non-DMI DSResponses. By default it is enabled for Hibernate and JPA datasources to avoid unintentional lazy loading too much of a data model. For the rest of datasources this is disabled by default.
Explicitly setting this property to
false
disables (or totrue
enables) this filtering for this DataSource only. This setting overrides the configuration inserver.properties
. This setting can be overridden byServerObject.dropExtraFields
.Default value is null
- See Also:
-
dbName
For DataSources using theSmart GWT SQL engine
for persistence, which database configuration to use. Database configurations can be created using theAdmin Console
. If unset, the default database configuration is used (which is also settable using the "Databases" tab).Default value is null
- See Also:
-
quoteTableName
For SQL DataSources, tells the framework whether to surround the associatedtable name
with quotation marks whenever it appears in generated queries. This is only required if you have to connect to a table with a name that is in breach of your database product's naming conventions. For example, some products (eg, Oracle) internally convert all unquoted references to upper case, so if you create a table calledmyTest
, the database actually calls itMYTEST
unless you quoted the name in the create command, like this:CREATE TABLE "myTest"
If you do quote the name like this, or if you have to connect to a legacy table that has been named in this way, then you must set this property to tell the SQL engine that it must quote any references to this table name (this requirement depends on the database in use - as noted below, some are not affected by this problem). If you do not, you will see exceptions along the lines of "Table or view 'myTest' does not exist".
Note, other database products (eg, Postgres) convert unquoted names to lower case, which leads to the same issues. Still others (eg, SQL Server) are not case sensitive and are not affected by this issue.
Generally, we recommend that you avoid using this property unless you have a specific reason to do so. It is preferable to avoid the issue altogether by simply not quoting table names at creation time, if you are able to do so.
Default value is null
-
fileLastModifiedField
The native field name used by this DataSource on the server to representfileLastModified
forFileSource Operations
.If the fileLastModifiedField is not configured, then a field named "fileLastModified" will be used, if it exists. Otherwise, the server will look for a field with a "modifierTimestamp" type. If that is not found, the DataSource will not keep track of the last modified date.
Default value is null
- See Also:
-
descriptionField
Name of the field that has a long description of the record, or has the primary text data value for a record that represents an email message, SMS, log or similar.For example, for a DataSource representing employees, a field containing the employee's "bio" might be a good choice, or for an email message, the message body.
If descriptionField is unset, it defaults to any field named "description" or "desc" in the record, or the first long text field (greater than 255 characters) in the record, or null if no such field exists.
Default value is null
-
serverObject
For Direct Method Invocation (DMI) binding, declares the ServerObject to use as the default target for alloperationBindings
. Specifying this attribute in an XML DataSource stored on the server enables DMI for this DataSource.Note that if a dataSource configuration has both a
<script>
block and a specifiedserverObject
for some operation, the script block will be executed, and the serverObject ignored.Default value is null
- See Also:
-
logSlowCustom
Allows you to specify"custom" operation
SQL query execution time threshold in milliseconds, which if exceeded query is identified as "slow" and may be logged under specific logging category.See
logSlowSQL
for more details.Default value is null
-
autoDeriveTitles
public boolean autoDeriveTitlesIf set, titles are automatically derived fromfield.name
for any field that does not have afield.title
and is not markedhidden
:true, by calling the methodgetAutoTitle()
.Default value is true
-
sparseUpdates
public boolean sparseUpdatesWhen true, indicates that any updates for this DataSource include only those fields that have actually changed (and primaryKey fields); when false (the default), all field values are included in updates, whether they have changed or notDefault value is false
-
strictSQLFiltering
If set to true, both client and server-side advanced filtering used by Smart GWT will follow SQL99 behavior for dealing with NULL values, which is often counter-intuitive to users. Specifically, when a field has NULL value, all of the following expressions are false:field == "someValue" (normally false) field != "someValue" (normally true) not (field == "someValue") (normally true) not (field != "someValue") (normally false)
This property can be overridden per-query by specifyingstrictSQLFiltering
directly as a property on theAdvancedCriteria
.NOTE: On the server side, this property is only applicable if you are using the SQL DataSource; the other built-in types (Hibernate and JPA/JPA2) do not offer this mode.
Default value is false
-
progressiveLoading
If true, causes Smart GWT Server to use the "progressive loading" pattern for fetches on this dataSource, as described in the Paging and total dataset length section of theResultSet documentation
. Essentially, this means that we avoid issuing a row count query and instead advertise total rows as being slightly more than the number of rows we have already read (seeendGap
). This allows users to load more of a dataset by scrolling past the end of the currently-loaded rows, but it prevents them from scrolling directly to the end of the dataset.Generally, progressive loading is appropriate when you have to deal with very large datasets. Note that by default, a dataSource will switch into progressive loading mode automatically when it detects that it is dealing with a dataset beyond a certain size - see
progressiveLoadingThreshold
.This setting can be overridden for individual fetch operations with the
OperationBinding.progressiveLoading
property, and also at the level of the individualDSRequest
. You can also specifyprogressiveLoading
onDataBoundComponents
and certain types ofFormItem
-SelectItem
andComboBoxItem
.Currently, this property only applies to users of the built-in SQLDataSource, but you could use it in custom DataSource implementations to trigger the server behavior described in the
ResultSet
documentation linked to above.Default value is null
-
configBean
For DataSources ofserverType
"hibernate", the name of a Spring bean to query to obtain Hibernate Configuration for this particular DataSource. Note that this is intended for DataSource-specific configuration overrides for unusual circumstances, such as a DataSource whose physical data store is a completely different database to that used by other DataSources. See theIntegration with Hibernate
article for more informationDefault value is null
- See Also:
-
schemaBean
For DataSources that specifyautoDeriveSchema
, this property indicates the name of the Spring bean, Hibernate mapping or fully-qualified Java class to use as parent schema.Default value is null
- See Also:
-
auditDSConstructor
For DataSources withauditing enabled
, optionally specifies theserverConstructor
for the automatically generated audit DataSource. The default is to use the sameserverConstructor
as the DataSource whereaudit="true"
was declared.This property is primarily intended to allow the use of SQLDataSource (
serverType:"sql"
) as an audit DataSource for a DataSource that might be of another type. For example, you might have a DataSource that implements all CRUD operations via Java logic inDMI declaration
methods, and so doesn't provide generic storage; by using SQLDataSource as the type of your audit DataSource, you don't need to implement your own scheme for storing and querying audit data, and the necessary audit tables will be automatically generated in the database.Similarly, even if you do use a reusable DataSource type such as the built-in JPADataSource, using SQLDataSource for audit DataSources means there's no need to write a JPA bean just to achieve storage of an audit trail.
To simplify this intended usage, the string "sql" is allowed for
auditDSConstructor
as a means of specifying that the built-in SQLDataSource class should be used. For any other type, use the fully qualified Java classname, as is normal forserverConstructor
.Default value is null
-
cacheSyncTiming
ThecacheSyncTiming
to use for operations on this DataSource. Can be overridden at theoperation
andDSRequest
levels. The default value of null is the same as specifying "immediate".Note that
cacheSyncTiming
is not applicable to many common types of request, and is simply ignored for these request types. See theCacheSyncTiming type documentation
for more details.Default value is null
- See Also:
-
cacheSyncStrategy
OperationBinding.cacheSyncTiming
com.smartgwt.client.data.DSRequest#getCacheSyncTiming
Automatic Cache Synchronization
-
templateConfigToken
The special token to look for when trying to resolve template references when thetemplate references mode
is "configOnly
". In this mode, the system looks for this token, followed by the strict pattern["property_name"]
(single quotes are allowed instead of double quotes, but that is the only supoprted variation).By default the template token is "
$config
" because that is the token used for Velocity templating, and is thus familiar. If you need to use a different token - perhaps because the "$" symbol already has special significance in your system - you can do so by setting this property. For example, if you settemplateConfigToken="#conf"
, your templated references would look like this:someProperty="#conf['my.property.name']"
Default value is "$config"
- See Also:
-
enumOrdinalProperty
The name of the property this DataSource uses for ordinal number when translating Java enumerated types to and from Javascript, if theEnumTranslateStrategy
is set to "bean". Defaults to "_ordinal" if not set.This property is only applicable if you are using the Smart GWT server
Default value is null
-
csvDelimiter
Applies to RestConnector dataSources (serverType
"rest") only, and is overridable per operationBinding (seeOperationBinding.csvDelimiter
).This property specifies the character to recognise as the delimiter when parsing REST service responses where the
responseFormat
is "csv"Default value is ","
- See Also:
-
useAnsiJoins
For DataSources using theSmart GWT SQL engine
for persistence, whether to use ANSI-style joins (ie, joins implemented with JOIN directives in the table clause, as opposed to additional join expressions in the where clause). The default value of null has the same meaning as setting this flag to false.Note, outer joins (see
joinType
) do not work with all supported database products unless you use ANSI joins. Other than that, the join strategies are equivalent.If you wish to switch on ANSI-style joins for every DataSource, without the need to manually set this property on all of them, set
server.properties
flagsql.useAnsiJoins
to true.Default value is null
-
requiresCompleteRESTResponse
Applies to RestConnector dataSources (serverType
"rest") only, and is overridable per operationBinding (seeOperationBinding.requiresCompleteRESTResponse
).If true, this flag indicates that the DataSource requires access to the entire REST response, not just the data part configured by the
recordXPath
. This is often the case for REST services that send back useful metadata alongside the data itself. For example, some REST services limit the number of records that can be retrieved in one service call, and will return the total number of records actually available in some kind of metadata property.This is useful information that a DataSource can use in custom logic to return a richer response to the client. This custom logic can be written in Java in a
DMI method
orcustom DataSource implementation
, or in any JSR223 scripting language, as aserver script
orresponse transformation script
.When this flag is true, the complete REST response is available to your server-side custom code as follows:
- For a DMI or custom dataSource implementation that
invokes the
RestConnector
built-in logic by callingexecute()
on either theDSRequest
or theDataSource
itself (this would be asuper()
call for a custom impl), theDSResponse
returned to your code will contain a property called "completeData" - For a
<script>
or<transformResponseScript>
, a variable called "completeData" will be available to your script (completeData is also available asdsResponse.completeData
)
DSResponse
will be serialized and returned to the client. If you do not want this, your custom server code should remove that property from theDSResponse
when it has finished with it.Default value is false
- See Also:
- For a DMI or custom dataSource implementation that
invokes the
-
showPrompt
Whether RPCRequests sent by this DataSource should enableRPCRequest.showPrompt
in order to block user interactions until the request completes.DataSource requests default to blocking UI interaction because, very often, if the user continues to interact with an application that is waiting for a server response, some kind of invalid or ambiguous situation can arise.
Examples include pressing a "Save" button a second time before the first save completes, making further edits while edits are still being saved, or trying to initiate editing on a grid that hasn't loaded data.
Defaulting to blocking the UI prevents these bad interactions, or alternatively, avoids the developer having to write repetitive code to block invalid interactions on every screen.
If an operation should ever be non-blocking, methods that initiate DataSource requests (such as
fetchData()
) will generally have arequestProperties
argument allowingshowPrompt
to be set to false for a specific request.Default value is true
-
defaultTextMatchStyle
The default textMatchStyle to use forDSRequest
s that do not explicitly state atextMatchStyle
. Note, however, that DSRequests issued byListGrid
s and othercomponents
will generally have a setting for textMatchStyle on the component itself (seeListGrid.autoFetchTextMatchStyle
, for example).Default value is "exact"
- See Also:
-
mockDataRows
WhenmockMode
is enabled, number of rows of data to retrieve via an initial "fetch" DSRequest, for use as sample data. Set to null to retrieve all available rows.Default value is 75
-
autoConvertRelativeDates
Whether to convert relative date values to concrete date values before sending to the server. Default value is true, which means that the server does not need to understand how to filter using relative dates - it receives all date values as absolute dates.If the server would receive relative date values from the client, by default they would be unchanged in DMI and automatically converted during the request execution. This may be changed via
server.properties
settingdatasources.autoConvertRelativeDates
which can be set to the following values:postDMI
- the default value described abovepreDMI
- relative date values will be converted to absolute date values right away, so they will be already converted in DMIdisabled
- relative date values will not be automatically converted, so it must be done completely manually or by calling theDSRequest.convertRelativeDates()
server-side API.DataSource.convertRelativeDates(Criterion)
server-side API.Default value is true
-
title
User-visible name for this DataSource.For example, for the supplyItem DataSource, "Supply Item".
If is unset,
getAutoTitle()
method will be used withdataSource.ID
. value in order to derive a default value for the title.For example "employee" ID will be derived to "Employee", "team_member" ID will be derived to "Team Member".
Default value is dataSource.ID
-
globalNamespaces
Namespaces definitions to add to the root element of outbound XML messages sent to a web service, as a mapping from namespace prefix to namespace URI.The default value is:
globalNamespaces : { xsi: "http://www.w3.org/2001/XMLSchema-instance", xsd: "http://www.w3.org/2001/XMLSchema" },
This default value allows the use of the xsi:type and xsi:nil attributes without further declarations.Note that some web services will only accept specific revisions of the XML Schema URI. If xsi-namespaced attributes seem to be ignored by an older webservice, try the URI "http://www.w3.org/1999/XMLSchema-instance" instead.
Default value is ...
-
sendExtraFields
Analogous todropExtraFields
, for data sent to the server. Setting this attribute to false ensures that for any records in the data object, only fields that correspond to declared dataSource fields will be present on the dsRequest data object passed totransformRequest()
and ultimately sent to the server.Default value is true
- See Also:
-
implicitCriteria
Criteria that are implicitly applied to all fetches made through this DataSource. These criteria are never shown to or edited by the user and are cumulative with any other criteria provided on the DSRequest.For example, a DataSource might *always* implicitly limit its fetch results to records owned by the current user's department. Components and ResultSets requesting data from the DataSource can then apply further implicitCriteria of their own, separately from their regular, user-editable criteria.
For instance, a grid bound to this dataSource might be further limited to implicitly show only the subset of records created by the current user. See
DataBoundComponent.implicitCriteria
andResultSet.implicitCriteria
for more on these localized options.Note that, while
implicitCriteria
can be declared in a server DataSource file usingComponent XML
, it is an entirely client-side feature, added by client-side components. So it does not affect server-side requests, and will not be added to client-side requests that don't come from a Smart GWT UI (eg RestHandler).Default value is null
-
pluralTitle
User-visible plural name for this DataSource.For example, for the supplyItem DataSource, "Supply Items".
Defaults to
dataSource.title
+ "s".Default value is dataSource.ID
-
tableName
For DataSources using theSmart GWT SQL engine
for persistence, what database table name to use. The default is to use the DataSource ID as the table name.Default value is null
- See Also:
-
unionOf
Only applicable to "union" dataSources, this is a comma-separated list of the names of the member dataSources that make up the union. If all the named dataSources areSQL DataSource
s, or union dataSources whose members are SQL dataSurces, the union will be implemented purely in SQL, which is the most efficient thing to do.Nesting Union DataSources
It is valid for union DataSources to be nested inside other union DataSources; nesting is valid to any depth. If you are nesting union dataSources, bear in mind the following considerations:- If you are renaming fields from underlying SQL DataSources in a union DataSource, and
you then include that union DataSource as a nested element of another union DataSource, it
is the renamed fields that should be referenced in the outer union DataSource. For example,
if you have union DataSource "union1" that specifes a unioned field like this:
<field name="c" unionOf="sqlDS1.a, sqlDS2.b" />
If you want to then include dataSource "union1" as a member dataSource of another union dataSource, "union2", you need to refer to the field as "c", not "a" or "b":<field name="myField" unionOf="union1.c, sqlDS3.xyz" />
Smart GWT will follow the chain of field renames to ensure that the appropriate SQL-level fields are unioned together, and renamed consistently - It is not an error to specify the same dataSource as a member
of a union dataSource multiple times, but it is also not correct and may have performance
implications. If you configure duplicate member dataSources directly, eg:
<DataSource serverType="union" unionOf="sqlDS1,sqlDS2,sqlDS1">
Smart GWT will simply remove the duplicate entries. However, with nested union dataSources, it becomes possible to indirectly include the same member dataSource more than once. Eg:<DataSource ID="bigUnion" serverType="union" unionOf="union1,union2">
and<DataSource ID="union1" serverType="union" unionOf="sqlDS1,sqlDS2">
and<DataSource ID="union2" serverType="union" unionOf="sqlDS2,sqlDS3">
You can see, dataSource "sqlDS2" is going to be included twice. This will result in the union DataSource generating SQL that fetches the rows from "sqlDS2" twice, but because of the way the SQL "UNION" keyword works, all the duplicate rows will be dropped. So the end result will be correct, but the system will have wasted time fetching and then dropping duplicate rows. - The ability to nest union dataSources within other union dataSources introduces a whole category of extra considerations. For example, you need to make sure you do not set up self references or looping structures, and as mentioned above, field renaming becomes potentially more involved
Default value is null
- See Also:
- If you are renaming fields from underlying SQL DataSources in a union DataSource, and
you then include that union DataSource as a nested element of another union DataSource, it
is the renamed fields that should be referenced in the outer union DataSource. For example,
if you have union DataSource "union1" that specifes a unioned field like this:
-
recordXPath
SeeOperationBinding.recordXPath
.recordXPath
can be specified directly on the DataSource for a simple read-only DataSource only capable of "fetch" operations, on clientOnly DataSources using String, or onRestConnector
dataSourcesDefault value is null
- See Also:
-
useSubselectForRowCount
This property is only applicable toSQL
DataSources, and only foroperations
that express acustomSQL
clause. In these circumstances, we generally switch off paging because we are unable to generate a "row count" query that tells the framework the size of the complete, unpaged resultset.The
useSubselectForRowCount
flag causes the framework to derive a rowcount query by simply wrapping the entire customSQL clause in a subselect, like so:
SELECT COUNT(*) FROM ({customSQL clause here})However, this is not guaranteed to give good results. Because the customSQL clause can contain anything that you can write in SQL, running it inside a subselect in order to count the rows might not work, might have unintended side-effects (if, for example, it is a stored procedure call that performs updates as part of its function), or it might just be a bad idea - for example, if the customSQL query is slow-running, you'll make it twice as slow with this flag, simply because you'll be running it twice. We recommend using this flag with care.
NOTE: This setting can be overridden per-operation - see
OperationBinding.useSubselectForRowCount
. You can also set a global default for this setting, so you don't have to specify it in every dataSource - defineuseSubselectForRowCount
as true in yourserver.properties
file.Default value is null
-
fileContentsField
The native field name used by this DataSource on the server to represent thefileContents
forFileSource Operations
.If the fileContentsField is not configured, then a field named "fileContents" or "contents" will be used, if it exists. If not found, the longest text field which is not the
fileNameField
,fileTypeField
orfileFormatField
will be used.Note that the only method which will actually return the fileContents is
getFile()
-- the otherFileSource
methods omit the fileContents for the sake of efficiency.Default value is null
- See Also:
-
serverType
For a DataSource stored in .xml format on the Smart GWT server, indicates what server-side connector to use to execute requests, that is, what happens if you call dsRequest.execute() in server code.Default value is "generic"
- See Also:
-
requestMaxRows
public int requestMaxRowsApplies toSQL DataSources
only.The same as
clientRequestMaxRows
, but applies to all requests, not just client-initiated ones. See the documentation forclientRequestMaxRows
for details. To reiterate the warning given for that property, this is a safety limit that results in an Exception being thrown: it is not intended to be used as a regular application facilityTo set a default
requestMaxRows
that will apply to all dataSources that do not specify the attribute, add the following to yourserver.properties
file:# Fail with an error if we try to fetch more than 50000 rows in any request sql.clientRequestMaxRows: 50000
Default value is -1
- See Also:
-
requestFormat
For aRestConnector DataSource
, the request format to use when contacting the remote REST service. Can be overridden at operationBinding level, seeOperationBinding.requestFormat
. Note, ifrequestFormat
is not specified at either the DataSource or OperationBinding level, the request will be rejected.Default value is null
- See Also:
-
preventHTTPCaching
If set, the DataSource will ensure that it never uses a cached HTTP response, even if the server marks the response as cacheable.Note that this does not disable caching at higher levels in the framework, for example, the caching performed by
ResultSet
.Default value is true
-
canMultiSort
public boolean canMultiSortWhen true, indicates that this DataSource supports multi-level sorting.Default value is true
-
requiresAuthentication
Whether a user must be authenticated in order to access this DataSource. This establishes a default for the DataSource as a whole; individualoperationBindings
within the DataSource may still override this setting by explicitly settingOperationBinding.requiresAuthentication
.Whether the user is authenticated is determined by calling
httpServletRequest.getRemoteUser()
, hence works with both simple J2EE security (realms and form-based authentication) and JAAS (Java Authentication & Authorization Service).If you wish to use an authentication scheme that does not make use of the servlet API's standards, Smart GWT Server also implements the
setAuthenticated
method onRPCManager
. You can use this API to tell Smart GWT that all the requests in the queue currently being processed are associated with an authenticated user; in this case, Smart GWT will not attempt to authenticate the user viahttpServletRequest.getRemoteUser()
You can set the default value for this property via setting "authentication.defaultRequired" in
server.properties
. This allows you to, for example, cause all DataSources to require authentication for all operations by default.Note that setting this property does not automatically cause an authentication mechanism to appear - you still need to separately configure an authentication system. Likewise, setting requiresAuthentication="false" does not automatically allow users to bypass your authentication mechanism - you need to set up a URL that will accept DSRequests and process them similar to the default "IDACall" servlet, and which is not protected by the authentication system. See
Deploying Smart GWT
for details on the IDACall servlet.Default value is null
- See Also:
-
logSlowFetch
Allows you to specify"fetch" operation
SQL query execution time threshold in milliseconds, which if exceeded query is identified as "slow" and may be logged under specific logging category.See
logSlowSQL
for more details.Default value is null
-
allowRelatedFieldsInCriteria
This property indicates whether this DataSource supports referencees to related fields in criteria, either using qualified field names, or subqueries. See thesubquery filtering overview
for details. Note, onlyAdvancedCriteria
can contain related fields.All server-side DataSource implementations provide a level of support for related fields in criteria, but only
SQL DataSources
can handle cases that require conditions to be considered simultaneously with a join to the outer dataSource.Default value is null
- See Also:
-
cacheSyncStrategy
ThecacheSyncStrategy
to use for operations on this DataSource. Can be overridden at theoperation
andDSRequest
levels.If
cacheSyncStrategy
is not explicitly set for aDataSource
, we will use the default strategy for thisDataSource type
. The defaults as shipped, are:Server Type Strategy sql requestValuesPlusSequences hibernate refetch jpa/jpa1 refetch rest responseValues generic refetch You can override these default strategies by adding a "
default.{server-type}.cache.sync.strategy
" setting to yourserver.properties
file, like these examples:default.sql.cache.sync.strategy: refetch default.rest.cache.sync.strategy: none
Note that globalcacheSyncStrategy
settings are defaults only; Smart GWT Server will override them intelligently in some circumstances. See the "CacheSyncStrategy" section of thecache synchronization overview
for details of when and why we do this.Default value is null
- See Also:
-
OperationBinding.cacheSyncStrategy
com.smartgwt.client.data.DSRequest#getCacheSyncStrategy
Automatic Cache Synchronization
-
titleField
Best field to use for a user-visible title for an individual record from this dataSource.For example, for a DataSource of employees, a "full name" field would probably most clearly label an employee record.
If not explicitly set, the titleField is determined by looking for fields named "name", "dataSourceIdName", "title", "dataSourceIdTitle", "label", "dataSourceIdLabel", "id" and "dataSourceIdId". For example, for a DataSource with ID "customer", a field called customerName would be found if there were no "name" field. Search is case insensitive, and an underscore is allowed after dataSourceId (so that, for example, "CUSTOMER_NAME" would also be found and preferred).
For purposes of this search, any trailing numerals in the DataSource ID are discarded, so a DataSource with ID "office2" will search for title fields as if the ID were just "office".
If no field is found that matches any of the names above, then the first field is designated as the titleField.
Default value is see below
-
defaultUnionFieldsStrategy
Only applicable to "union" dataSources. Determines the strategy we adopt when automatically deriving a list of fields when no explicitunionFields
setting is provided. Note that explicit field declarations that includeunionOf
definitions take precedence over whateverdefaultUnionFieldsStrategy
is defined. As an example of how this property affects field derivation, assume our unionDataSource specifies three member dataSources in itsunionOf
setting:- ds1 has fields f1 (integer), f2 (text) and f3 (boolean)
- ds2 has fields f1 (integer), f2 (text) and f4 (datetime)
- ds3 has fields f1 (integer), f2 (float), f4 (datetime) and f5 (text)
- intersect would give just f1 (f2 exists on every dataSource, but the data type is not the same in every case)
- matching would derive f1 and f4 - again, f2 would be excluded because of the data type discrepancy. Records from ds1 would contribute a null value for f4
- all would derive all fields except f2, excluded because of the data type discrepancy. Values for missing fields from any given dataSource would be null
Default value is "matching"
-
multiInsertBatchSize
For dataSources ofserverType
"sql" only, this property sets the multi-insert batch size for add requests on thisdataSource
. Only has an effect if theadd request
specifies a list of records as the data, and only ifmultiInsertStrategy
is set to "multipleValues", either globally or at theDSRequest
,OperationBinding
, orDataSource
level.The multi-insert batch size determines the maximum number of
VALUES
clauses Smart GWT Server will generate for a singleINSERT
operation. The optimum value for this setting depends on the underlying database, but typically larger batches yield better performance. if the number of records in the request exceeds the batch size, we break it up into however many batches are required. For example, if the batch size is 55 and the request contains 200 records, we would create 4 databaseINSERT
operations - 3 with 55VALUES
clauses, and a final one with the remaining 35.Note that this setting (along with the other multi-insert properties,
multiInsertStrategy
andmultiInsertNonMatchingStrategy
) can be overridden at theoperationBinding level
and thedsRequest level
. If you wish to configure multi-insert setting globally, see the documentation formultiInsertStrategy
.Default value is null
-
allowAggregation
This property indicates whether this DataSource supports aggregation/summarization of field values using thesummaryFunction
mechanism. Of thebuilt-in DataSource types
, SQL, Hibernate and JPA DataSources allow aggregation, as doclientOnly
DataSources.If you create a custom DataSource type that can handle the summary functions described in the overview linked above, you should set this flag true to indicate to Smart GWT that summary functions should be allowed - for example, in the
FilterBuilder
.Default value is null
- See Also:
-
csvQuoteCharacter
Applies to RestConnector dataSources (serverType
"rest") only, and is overridable per operationBinding (seeOperationBinding.csvQuoteCharacter
).This property specifies the character to treat a string quotation mechanism when parsing REST service responses where the
responseFormat
is "csv". Text in CSV responses does not have to quote string data, but many uses of CSV do quote strings because it allows text in the data to contain occurences of thecsvDelimiter
. For example, if thecsvDelimiter
is the default value of ",", quoting allows the following text, which would otherwise be ambiguous:1,ABC,"This is a text string, with a comma in the middle"
Default value is '"'
- See Also:
-
creatorOverrides
Indicates that declarative security rules are waived for rows that were created by the current user. Practically, this means that when a security check fails, instead of a security exception being thrown, we alter the criteria to ensure that the request can only return or affect rows that were created by the current authenticated user. This allows you to create security regimes whereby users can see and edit data they created, but have access to other users' data forbidden or limited.In order for this to work, we require two things:
- The DataSource must specify a field of type "creator" - this field type is described
on
this page
- The authentication regime in use must include the idea of a "current user". The authentication provided by the Servlet API is an example of such a regime.
Default value is null
- The DataSource must specify a field of type "creator" - this field type is described
on
-
resultSetClass
Class for ResultSets used by this datasource. If null, defaults to usingResultSet
.This can be set to a custom subclass of ResultSet that, for example, hangs onto to extra information necessary for integration with web services.
Default value is null
-
logSlowSQL
Allows you to specify SQL query execution time threshold in milliseconds, which if exceeded query is identified as "slow" and may be logged under specific logging category.This setting applies to all SQL queries, unless more specific thresholds are set using
logSlowFetch
,logSlowAdd
,logSlowUpdate
,logSlowRemove
,logSlowCustom
or even more specific affecting just the operationBinding it is configured in your DS XML as operationBinding.logSlowSQL.If none of the thresholds above are set, global sql.log.queriesSlowerThan
server.properties SQL setting
will be used.For the details on how to setup the logging part see the
Special logging category: com.isomorphic.SLOW_SQL
Default value is null
-
ownerIdNullAccess
IfownerIdField
is in force, specifies the access that is allowed to records with a nullownerIdField
. This property has no effect ifownerIdField
is not specified.This property can be used in conjunction with
ownerIdNullRole
to create the concept of shared, or public, records. For example, if you setownerIdNullRole
to "administrator", any users with the "administrator" role will be allowed to write records with a nullownerIdField
. If you also setownerIdNullAccess
to "view", all those records with a null owner will be viewable by all, in addition to their own records. We use this functionality with theSaved Searches feature
, to enable precisely this: users can save their own searches, which are private to them, but administrators can also save searches with a nullownerIdField
, which become standard, shared searches that appear to all users, in addition to their own private searches.Default value is null
- See Also:
-
iconField
Designates a field oftype
:"image" as the field to use when rendering a record as an image, for example, in aTileGrid
.For example, for a DataSource of employees, a "photo" field of type "image" should be designated as the iconField.
If not explicitly set, iconField looks for fields named "picture", "thumbnail", "icon", "image" and "img", in that order, and will use any of these fields as the iconField if it exists and has type "image".
To avoid any field being used as the iconField, set iconField to
null
.Default value is see below
-
forceSort
For DataSources ofserverType
"sql" only, indicates whether we should automatically add a sort field forpaged fetches
on this DataSource. If left unset, this property defaults to the one of the global values described in thedefaultSortField
documentation. Also note, this property can be overriddenper-operationBinding
.Note, the ability to set this property per-DataSource is only provided to allow for complete configurability in unusual cases. See the
defaultSortField
docs for details of why use of this property should be considered a red flag.Default value is null
- See Also:
-
addedAuditFields
The list of extra manually managed fields that will be added to thefields
of theAudit DataSource
.This feature enables the storage of additional information in the
Audit DataSource
alongside the standard audit data. In order to do that the audited DataSource needs to declareauditDSConstructor
referring customserverConstructor
, so that all requests to add data to the Audit DataSource could be intercepted allowing to make changes to the new records (obtained usingDSRequest.getValues()
server-side API). In this particular use case values for theaddedAuditFields
need to be provided.Example of an audited DataSource (schematically):
<DataSource audit="true" auditDSConstructor="package.AuditDS"> <fields>....</fields> <addedAuditFields> <addedAuditField name="altitude" type="float" /> <addedAuditField name="longitude" type="float" /> <addedAuditField name="logCorrelationId" type="text" /> </addedAuditFields> </DataSource>
An example implementation of AuditDS could be as follows:public class AuditDS extends SQLDataSource { public DSResponse executeAdd(DSRequest req) throws Exception { // populate additional fields Map values = req.getValues(); values.put("altitude", 54.685); values.put("longitude", 25.286); values.put("logCorrelationId", "foobar"); // execute "add" request return super.executeAdd(req); } }
Default value is null
- See Also:
-
fields
The list of fields that compose records from this DataSource.Each DataSource field can have type, user-visible title, validators, and other metadata attached.
Default value is null
- See Also:
-
ownerIdNullRole
IfownerIdField
is in force, specifies a role that will allow theownerIdField
to take a null value. Any user that has that role is allowed to create client-initiated "add" and "update" operations that specify a null value for theownerIdField
, and the system will persist the null value rather than forcing in the currently authenticated user's user id as it normally would. If any client-initiated "add" or "update" request specifies any non-null value for theownerIdField
, the normal behavior of the system will reassert and the current user's user id will be forced into theownerIdField
. This allows authorised users (ie, those with the necessary role) to choose between saving public or private records, just by sending a null or non-null value for theownerIdField
.This property has no effect if
ownerIdField
is not specified.This property can be used in conjunction with
ownerIdNullAccess
to create the concept of shared, or public, records - see that property's documentation for an example.Default value is null
- See Also:
-
endGap
public int endGapIf we areloading progressively
, indicates the number of extra records Smart GWT Server will advertise as being available, if it detects that there are more records to view (seelookAhead
). This property has no effect if we are not progressive-loading.Note that when viewing DataSource data in a ListGrid, it is not recommended to have the endGap be larger than the
ResultSet.resultSize
. This can result in a situation where the entire range requested by the ResultSet is beyond the true end of the data set, with unpredictable results.Default value is 20
- See Also:
-
omitNullDefaultsOnAdd
public boolean omitNullDefaultsOnAddWhen true, andnoNullUpdates
is also true, indicates that "add" requests on this DataSource will have null-valued fields removed from the request entirely before it is sent to the server, as opposed to the default behavior of replacing such null values with defaults.Default value is false
- See Also:
-
nullStringValue
IfnoNullUpdates
is set, the value to use for any text field that has a null value assigned on an update operation, and does not specify an explicitnullReplacementValue
.Default value is ""
- See Also:
-
noNullUpdates
com.smartgwt.client.docs.serverds.DataSourceField#nullReplacementValue
-
useOfflineStorage
Whether we store server responses for this DataSource intobrowser-based offline storage
, and then use those stored responses at a later time if we are offline (ie, the application cannot connect to the server). Note that by default we do NOT use offline storage for a dataSource.Default value is null
-
params
Applies to RestConnector dataSources (serverType
"rest") only, and is overridable per operationBinding (seeOperationBinding.params
).A list of key/value pairs to pass as URL parameters when constructing the query part of the REST service URL. These can include templating, as described in the
RestConnector overview
. For example:<params> <customParam>$arbitraryVarInTemplateContext</customParam> <userIdentifier>$config['rest.service.user.identifier']</userIdentifier> </params>
Bear in mind thatrequestFormat
"params" implies by default a behavior that automatically adds parameters corresponding to values and/or criteria (see theRESTRequestFormat
docs for details), so you would not normally use this property to specify parameters based on request values. Any params explicitly specified with theparams
property at DataSource of operationBinding level will be added to the auto-created list of params implied ifrequestFormat
is "params".Default value is null
- See Also:
-
projectFileKey
For DataSources with type
, looks up the locations to use asprojectFile
projectFileLocations
from the project's configuration (i.e. project.properties,server.properties
etc.).For instance, to look up the value of project.datasources and use it for
projectFileLocations
, use "datasources" as theprojectFileKey
.If you specify both
projectFileKey
andprojectFileLocations
, then both with be used, with theprojectFileLocations
applied last.Default value is null
- See Also:
-
logSlowUpdate
Allows you to specify"update" operation
SQL query execution time threshold in milliseconds, which if exceeded query is identified as "slow" and may be logged under specific logging category.See
logSlowSQL
for more details.Default value is null
-
useSpringTransaction
This flag is part of the Automatic Transactions feature; it is only applicable in Power Edition and above.If true, causes all transactional operations on this DataSource to use the current Spring-managed transaction, if one exists. If there is no current Spring transaction to use at the time of execution, a server-side Exception is thrown. Note, a "transactional operation" is one that would have joined the Smart GWT shared transaction in the absence of Spring integration - see
auotJoinTransactions
.This feature is primarily intended for situations where you have
DMI methods
that make use of both Spring DAO operations and Smart GWT DSRequest operations, and you would like all of them to share the same transaction. An example of the primary intended use case:@Transactional(isolation=Isolation.READ_COMMITTED, propagation=Propagation.REQUIRED) public class WorldService { public DSResponse doSomeStuff(DSRequest dsReq, HttpServletRequest servletReq) throws Exception { ApplicationContext ac = (ApplicationContext)servletReq.getSession().getServletContext().getAttribute("applicationContext"); WorldDao dao = (WorldDao)ac.getBean("worldDao"); dao.insert(req.getValues()); DSRequest other = new DSRequest("MyOtherDataSource", "add"); // Set up the 'other' dsRequest with critiera, values, etc // ... // This dsRequest execution will use the same transaction that the DAO operation // above used; if it fails, the DAO operation will be rolled back other.execute(); return new DSResponse(); } }
Note: if you want to rollback an integrated Spring-managed transaction, you can use any of the normal Spring methods for transaction rollback:- Programmatically mark the transaction for rollback with the
setRollbackOnly()
API - Throw a
RuntimeException
, or - Throw an ordinary checked
Exception
. but configure Spring to rollback on that Exception. This can be done in the @Transactional annotation:@Transactional(isolation=Isolation.READ_COMMITTED, propagation=Propagation.REQUIRED, rollbackFor=MyRollbackException.class)
Exception
; but Spring will ignore thatException
. So you can either:- Wrap every
DSRequest.execute()
in a try/catch block. CatchException
and throw aRuntimeException
instead - Just use the "rollbackFor" annotation to make your transactional method rollback
for all instances of
Exception
Note: Spring transaction integration is conceptually different from Smart GWT'sbuilt-in transaction feature
, because Smart GWT transactions apply to a queue of DSRequests, whereas Spring transactions are scoped to a single method invocation. If you want to make a whole Smart GWT queue share a single Spring-managed transaction, you can wrap the processing of an entire queue in a call to a transactional Spring method. See the Using Spring Transactions with Smart GWT DMI section at the bottom of theSpring integration page
for more details.You can set
useSpringTransaction
as the default setting for all dataSources for a given database provider by adding the property{dbName}.useSpringTransaction
to yourserver.properties
file. For example,Mysql.useSpringTransaction: true
orhibernate.useSpringTransaction: true
. You can set it as the default for all providers with aserver.properties
setting like this:useSpringTransaction: true
. WhenuseSpringTransaction
is the default, you can switch it off for a specific dataSource by explicitly setting the flag to false for that DataSource.Finally, this setting can be overridden at the operationBinding level - see
OperationBinding.useSpringTransaction
Configuration
When using Spring transactions, Smart GWT needs a way to lookup the JNDI connection being used by Spring, and this needs to be configured. First, register a bean like this in your applicationContext.xml file:<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <!-- Set this to the JNDI name Spring is using --> <property name="jndiName" value="isomorphic/jdbc/defaultDatabase"/> </bean>
and then add a line like this to your server.properties:# Set this property to match the "id" of the JndiObjectFactoryBean registered in Spring sql.spring.jdbcDataSourceBean: dataSource
Default value is null
- Programmatically mark the transaction for rollback with the
-
transformResponseScript
A scriptlet to be executed on the server after running any operation on this dataSource. The intention is that this scriptlet transforms the response data in some way. It is provided to allow complex, programmatic transformations without having to handle the operation in a DMI orhandler script
. To avoid confusion, it should be noted that, in many cases, you could instead write response transformation logic in ascript
that first invokes execute() on the DSRequest to run the default behavior. The advantage oftransformResponseScript
is that it allows you partition any script logic appropriately, and is more self-documenting.If
OperationBinding.transformResponseScript
is also specified, it will be executed for the operation binding in question in addition to and after the DataSource-level script.All of the variables available in a normal
script
are available to atransformResponseScript
, but the framework also provides somes additional variables useful in the specific context of transforming response data:- dsResponseThe actual
DSResponse
object - responseObjects
is the response data as a list of objects, either Maps or Javabeans, depending on what data
model you are using - see
beanClassName
. If the underlying response data is actually a single object, this is just that single object wrapped in a List - responseObject is the response data as a single object. If the underlying response data is not a single object - ie, it is a list of objects - this will just be the first item in the list
server-side RestConnector
, a number of additional variables are made available:- responseText is the actual XML or JSON text returned by the REST service
- completeData is the entire REST
response converted into a structure of Java Lists and Maps by parsing the JSON or XML text
(note, only if the
requiresCompleteRESTResponse
flag is true) - responseRecords is the REST
response converted into a list of records, either by:
- Parsing a list-type response from the JSON or XML text returned by the REST service, or
- Parsing the response and
then applying the
recordXPath
, if a recordXPath is declared
responseRecords
is provided to the script as a List of Maps. If the dataSource expresses a responseTemplate, it is the list of records after templating has been processed - responseRecordsBeforeTemplating is
the
responseRecords
as they were before theresponseTemplate
was applied. It is only present if the dataSource declares aresponseTemplate
responseObjects
and (for RESTDataSource only)responseRecords
are "live". This means that any changes you make to them in your script will affect the underlying objects in the response data and be seen in downstream processing. This means that your script can modify things in place and does not need to return a value; this is the recommended approach.If your script does return a value, we will assign that value as the response data on return from the script.
Warning: It is advisable to explicitly return null if you do not wish to return a value. See the section "Returning values and JavaScript", which also applies to Groovy and some other JSR223 languages, in the
server scripting overview
.Note, if you prefer a Java solution rather than placing scripts in your
.ds.xml
files, you can instead extend the JavaBasicDataSource
class and override itstransformResponse()
method. If you both override the Java method and provide atransformResponseScript
, the Java method runs first and any transformations it makes will be visible to the script. SeeserverConstructor
for details of how to use a custom class to implement a DataSource server-side.Default value is null
- dsResponseThe actual
-
transformRequestScript
A scriptlet to be executed on the server prior to running any operation on this dataSource. The intention is that this scriptlet transforms the DSRequest in some way - probably itscriteria
and/orvalues
, but maybe something less obvious, such as adding to its templateContext Map - prior to running the operation proper. It is provided to allow more complex, programmatic transformations than is possible with declarativeDSRequestModifier
s, without having to handle the operation in a DMI orhandler script
. To avoid confusion, it should be noted that, in many cases, you could instead write request transformation logic in ascript
and then have that script invoke execute() on the DSRequest to proceed with default behavior. The advantage oftransformRequestScript
is that it allows you partition any script logic appropriately, and is more self-documenting.If
OperationBinding.transformRequestScript
is also specified, it will be executed for the operation binding in question in addtion to and after the DataSource-level script.All of the variables available in a normal
script
are available to atransformRequestScript
, including the three you are most likely to use:dsRequest
,criteria
andvalues
. All three of these variables are "live" - any changes you make to them will affect the underlying object and be seen in downstream processing. This means that your script can modify things in place and does not need to return a value; this is the recommended approach.If your script does return a value, we will assign that value to criteria for a fetch or remove operation, and to values for an add or update operation. This may well be what you want, but it may not - this is why we recommend modifying in place and not returning a value.
Warning: It is advisable to explicitly return null if you do not wish to return a value. See the section "Returning values and JavaScript", which also applies to Groovy and some other JSR223 languages, in the
server scripting overview
.Default value is null
-
defaultBooleanStorageStrategy
ForserverType:"sql"
DataSources, sets the defaultsqlStorageStrategy
to use for boolean fields where nosqlStorageStrategy
has been declared on the field.Can also be set system-wide via the
Server_properties
settingsql.defaultBooleanStorageStrategy
, or for a particular database configuration by settingsql.dbName.defaultBooleanStorageStrategy
(seeAdmin Console overview
for more information on SQL configuration).Note that when this property is unset, the default
DataSourceField.sqlStorageStrategy
strategy is effectively "string".Default value is null
- See Also:
-
defaultMultiUpdatePolicy
Controls when primary keys are required for "update" and "remove" server operations, when allowMultiUpdate has not been explicitly configured on either theoperationBinding.allowMultiUpdate
or via the server-side APIDSRequest.setAllowMultiUpdate()
.Default value of null means this DataSource will use the system-wide default, which is set via
datasources.defaultMultiUpdatePolicy
inserver.properties
, and defaults to not allowing multi updates for requests associated with an RPCManager, seeMultiUpdatePolicy
for details.Default value is null
- See Also:
-
useParentFieldOrder
For a DataSource that inheritsfields
from another DataSource (viainheritsFrom
), indicates that the parent's field order should be used instead of the order of the fields as declared in this DataSource. New fields, if any, are placed at the end.Default value is null
-
idClassName
For JPA and Hibernate DataSources this property indicates, that data source has composite primary key and specifies fully-qualified Java class:- with
@EmbeddedId
you have to specify class name of declared id - with
@IdClass
you have to specify class specified in annotation declaration
Default value is null
- with
-
auditChangedFieldsFieldName
For DataSources withauditing enabled
, specifies the field name used to store the names of the fields which were updated. If empty string is specified as the field name, the audit DataSource will not store this field.Note that this field will only be set for
update
operations.Default value is "audit_changedFields"
-
defaultSortField
For DataSources ofserverType
"sql" only, the name of a field to include in theORDER BY
clause as a means of enforcing a stable sort order, forpaged fetches
only. This property has no effect for non-SQL dataSources, or for non-paged fetches.Generally speaking, databases make no guarantee about the order of rows in a resultset unless an
ORDER BY
clause was provided. This is not usually a problem if you actually don't care about the row order, but there is a catch if you are using paged fetching: because the pages are fetched using completely different queries, the database is at liberty to use different orderings from one fetch to another, and in some cases, with some databases, that is what actually happens. This leads to broken paging behavior, with some records duplicated and others omitted.Note that it is unusual for a database to change strategies between queries like this; generally speaking, rows are ordered in some kind of natural ordering in the absence of an explicit order - typically insertion order, or by primary key value. However, it does happen, and is more likely with some database products than others.
This property only has an effect if
forceSort
is in effect for the fetch operation. See below for DataSource- and operation-level options, but ordinarily this is arranged by setting theforceSort
property for the current database configuration in yourserver.properties
file:# Given this database definition sql.MyDB.database.type: mysql # Either of these settings will enable automatic sorting sql.MyDB.forceSort: true # Or sql.mysql.forceSort: true
Note, thedefaultSortField
should ideally provide a unique ordering: so for an employee table, payroll number would be preferable to employee name. A non-unique ordering will usually be sufficient to ensure stablity of ordering from one query to the next, because it will usually ensure that the database is forced to use the same index in each case. However, the database may still choose to order rows differently within the confines of the non-unique ordering, so only a unique ordering is guaranteed to ensure stability.Fields of
type
creatorTimestamp
are also good candidates for this purpose - assuming you have a suitable index in place, and assuming sorting by temporal values does not introduce performance problems with your database of choice - as they are often unique or near-to-unique, and they reflect the insertion order, which is the "natural ordering" in some (not all) databases.Note that this automatic sorting does not interfere with the ordinary sorting that your application may do: it is applied in addition to any application sort order. So if your application imposes no
sort order
, the resultset will be sorted by thedefaultSortField
; if your application requests a sort order of, eg, "state" then "city", the resultset will be ordered by "state", then "city", and then thedefaultSortField
If
forceSort
is enabled and you do not provide adefaultSortField
for a given database, Smart GWT will instead use theprimaryKey
field(s). If the dataSource does not define aprimaryKey
, we will just use the dataSource's first defined field. Recommendation: Unless you have a reason to explicitly declare adefaultSortField
, we recommend that you leave it undefined for any DataSource that declares aprimaryKey
(and we recommend that all dataSources declare aprimaryKey
). TheprimaryKey
field is usually the ideal candidate for this purpose, because it is unique and almost certainly indexed.Note that
forceSort
is enabled by default for PostgreSQL, because this product is known to be less likely to retain a stable sort order between two similar, unordered queries.DataSource- and OperationBinding-level forceSort flag
As well as the above-mentioned global settings, it is possible to configure automatic sorting behavior for paged fetches at both the individualDataSource level
andoperationBinding level
. However, this facility is only provided to allow complete configurability in unusual cases. Generally speaking, if a database requires ordering for correct behavior with paged fetches, it always requires ordering for correct behavior with paged fetches; you can't ordinarily pick and choose which tables or which individual fetches need to be ordered.That said, there may be real world cases where a database that normally requires ordering for correct behavior, nevertheless has individual cases where that is not required - maybe on tables that have only a single index, or in cases where there are no joins involved, or maybe in other circumstances related to how that specific database product works internally. Or again, there may be unusual individual cases where a database that ordinarily works fine for paged fetches without requiring ordering, needs to apply an ordering.
We provide the DataSource- and operation-level
forceSort
flags to allow you to work around or take advantage of these database-specific quirks. However, use of them should be considered a red flag because they might cause problems if things change in the future (new database release, change in the underlying query, addition of a foreignKey relation at the database level, etc).Default value is null
- See Also:
-
autoDeriveSchema
This property allows you to specify that your DataSource's schema (field definitions) should be automatically derived from some kind of metadata. This causes Smart GWT to create a special super-DataSource, which is used purely as a source of default schema for this DataSource; this is arranged by causing the autoDerived DataSource to automaticallyinherit from
the special super-DataSource. This allows you to auto-derive schema from existing metadata, whilst still being able to override any or all of it as required. By default additional derived field definitions are placed at the end, but that can be changed byuseParentFieldOrder
flag. Also, derived field definitions may be hidden usingshowLocalFieldsOnly
.This property has a different implementation depending upon the
serverType
of the DataSource:- For a DataSource with serverType: "sql", automatically derive the dataSource's schema
from the Spring bean or Java class specified in
schemaBean
. IfschemaBean
is not specified, derive the schema from the columns in the SQL table specified intableName
. More information on SQL DataSources ishere
- For a DataSource with serverType: "hibernate", automatically derive the dataSource's
schema from the Spring bean, Hibernate mapping or Java class named in the
schemaBean
property. If no such thing exists, derive the schema from the Hibernate mapping or Java class specified in thebeanClassName
property (this allows you to specify schema and mapping separately, in the unusual circumstance that you have a need to do so). Note that the "mappings" referred to here can mean either.hbm.xml
files or annotated classes; both are supported. If neither of these is successful, derive the schema from the underlying SQL table specified intableName
. More information on Hibernate DataSources ishere
- For a DataSource with serverType: "jpa1" or "jpa", automatically derive the
dataSource's schema from the annotated JPA class named in the
schemaBean
property. If the schemaBean property is not defined, derive the schema from the annotated JPA class named in thebeanClassName
property (as with Hibernate, this allows you to specify schema and mapping separately if you need to do so). JPA DataSource generation relies on annotations (the orm.xml mapping file is not supported). More information on JPA DataSources ishere
- For other DataSource types, attempt to find a Spring bean with the name specified in
the
schemaBean
property. If no such bean is found (or Spring is not present), attempt to instantiate an object whose fully-qualified class name is the value in theschemaBean
property. If one of these approaches succeeds, we derive the schema from the discovered object (by treating it as a Java Bean and assuming that each one of its getters corresponds to a like-named field in the DataSource). More information on custom DataSource implementations ishere
.
primary key
fields at the top.Field types
The following table shows how SQL types are derived intoDataSource types
when we use an SQL table as a source of metadata for a SQL or Hibernate DataSource:SQL type DataSource type
CHAR, VARCHAR, LONGVARCHAR, TEXT, CLOB text BIT, TINYINT, SMALLINT, INTEGER, BIGINT, DECIMAL*, NUMBER** integer REAL, FLOAT, DOUBLE, DECIMAL*, NUMBER** float DATE date TIME time TIMESTAMP datetime BLOB, BINARY, VARBINARY, LONGVARBINARY binary
**NUMBER is an Oracle-only type that appears in the JDBC metadata as DECIMAL and is handled exactly the same way as DECIMALThe following table shows how Java types are derived into DataSource types when we use an unannotated Java class (Spring bean, Hibernate mapping or POJO) as a source of metadata for a SQL, Hibernate or custom DataSource:
Java type DataSource type
boolean, Boolean boolean char, Character, String, Reader text byte, short, int, long, Byte, Short, Integer, Long, BigInteger integer float, double, Float, Double, BigDecimal float Enum enum (see discussion below) InputStream binary java.sql.Date, java.util.Date, java.util.Calendar date java.sql.Time time java.sql.Timestamp datetime Finally, this table shows how Java types are derived into DataSource types when we use an annotated class as a source of metadata. Note annotated classes are necessary for JPA DataSources, but you can choose to use them for other types of DataSource as well. For Hibernate DataSources, this is very worthwhile because Hibernate will also make use of the annotations as config, meaning you don't need to specify
.hbm.xml
files. For SQL and custom DataSources, there is no benefit at the persistence level, but it may still be worthwhile because the use of an annotated class gives us better metadata and allows us to generate a better, closer-fitting autoDerive DataSource than we can from examination of SQL schema or plain Java Beans:Java type DataSource type
boolean, Boolean boolean char, Character, String, Reader text byte, short, int, long, Byte, Short, Integer, Long, BigInteger integer float, double, Float, Double, BigDecimal float InputStream binary java.util.Date (with Temporal set to DATE), java.sql.Date date java.util.Date (with Temporal set to TIME), java.sql.Time time java.util.Date (with Temporal set to TIMESTAMP), java.util.Calendar, java.sql.Timestamp datetime Enum (with Enumerated set to STRING) enum (see discussion below) Enum (with Enumerated set to ORDINAL) intEnum (see discussion below) Field with Lob annotation binary Field with GeneratedValue annotation sequence, if the field is an integer type (see discussion below) Primary keys, sequences and identity columns
We attempt to derive information about primary keys from the metadata we have.If the metadata source is an SQL table:
- If the table does not have a native primary key constraint, no attempt is made to identify primary key fields. Otherwise:
- The column or columns that make up the table's native primary key constraint are
identified using the JDBC
DatabaseMetaData.getPrimaryKeys()
API - Each DataSource field that corresponds to one of these native primary key columns
is marked
primaryKey: true
- For each of these columns, the metadata returned by
DatabaseMetaData.getColumns()
is inspected. If the metadata includesIS_AUTOINCREMENT=YES
, we mark the corresponding field astype="sequence"
. This information should be reliably provided by databases that implement "auto-increment" or "identity" column types, such as MySQL or Microsoft SQL Server - If the previous step does not identify a column as a sequence, we inspect the
ResultSetMetaData
obtained by running a dummy query on the table. If theisAutoIncrement()
API returns true for that column, we mark the corresponding field astype="sequence"
- If the previous steps have not identified the column as a sequence, we check the
TYPE_NAME
in the column metadata. If it is "serial", this means the column is a PostgreSQL "serial" or "serial8" type column. Postgres does not transparently implement auto-increment columns, but it does provide this serial type, which causes the column to be implicitly bound to an underlying sequence. So this type causes us to mark the fieldtype="sequence"
, and we also setimplicitSequence
true - If the previous steps have not identified the column as a sequence, we check the
COLUMN_DEF
in the column metadata. If this contains the token "$$ISEQ" and ends with "NEXTVAL", this means the column is an Oracle "GENERATED AS IDENTITY" column. This type of column was introduced in Oracle 12c and is conceptually exactly the same thing as the Postgres "serial" column described above. We treat it the same way: mark ittype="sequence"
andimplicitSequence="true"
- If the previous steps have not identified the column as a sequence, then you may
be using a pure sequence database, such as an Oracle version earlier than 12c, or
you may be using a database where both sequences and identity columns are available
(Oracle, Postgres, DB2), and a sequence is being used either by design or because
the table was created before the database product supported identity columns. In
this case, we cannot determine if the column should be a sequence or not. However,
in many applications, the fact that the column is an integer and is a primary key
would imply that it is also a sequence. Therefore, if the column is an integer and
the
server.properties
flagauto.derive.integer.pk.always.sequence
is true, we mark the field astype="sequence"
- If, after all this, Smart GWT ends up incorrectly marking a primary key field as
a sequence (or vice versa), you can always override it on a per-field basis by
simply redeclaring the field with the correct type in your
.ds.xml
file:<DataSource serverType="sql" tableName="myTable" autoDeriveSchema="true"> <fields> <!-- This field was incorrectly marked as a sequence --> <field name="notASeq" type="integer" /> <!-- This field was incorrectly marked as an integer when it should be a sequence --> <field name="isASeq" type="sequence" /> </fields> </DataSource>
If the metadata source is Hibernate mappings described in a
.hbm.xml
file:- The first field we encounter that is described in the mapping with an <id> tag is marked as a primaryKey
- If that field is marked as being generated, we set its type to "sequence"
If the metadata source is an annotated object (whether JPA, Hibernate or just an annotated POJO):
- Any field with an
@Id
annotation is is marked as a primaryKey (this differs from the Hibernate.hbm.xml
file case because that is specific to Hibernate, which does support composite keys, but not by specifying multiple <id> tags. Annotations are supported, via annotated POJOs, for any kind of persistence strategy, so multiple@Id
fields are perfectly valid) - Any field with a
@GeneratedValue
annotation is either marked astype="sequence"
(if it is an integer type) or as
(for other field types)autoGenerated
="true"
enums and valueMaps
When we come across JavaEnum
properties in plain or annotated classes, as well as setting the field type as noted in the above tables, we also generate a valueMap for the field, based on theEnum
members.For cases where we generate a field of Smart GWT type "enum" (see the above tables), the keys of the valueMap are the result of calling
name()
on each member of the underlying Java Enum (in other words, its value exactly as declared in its enum declaration). For cases where we generate a field of Smart GWT type "intEnum", the keys of the valueMap are strings representing the ordinal number of each member in the Java Enum - "0", "1", etc. Note that this behavior will be overriden byDataSource.enumTranslateStrategy
if both are set.In both of these case, the display values generated for the valueMap are the result of calling
toString()
on each Enum member. If that gives the same value as callingname()
, the value is passed throughDataTools.deriveTitleFromName()
, which applies the same processing rules asgetAutoTitle()
to derive a more user-friendly display value.Further notes
schemaBean
impliesautoDeriveSchema
, because it has no other purpose than to name the bean to use for auto-derived schema. Thus, if you specifyschemaBean
you do not need to specifyautoDeriveSchema
as well (though it does no harm to do so). However,tableName
andbeanClassName
can be validly specified without implyingautoDeriveSchema
, so in those cases you must explicitly specifyautoDeriveSchema
.The underlying super-DataSource is cached in server memory, so that it does not have to be derived and created each time you need it. However, the cache manager will automatically refresh the cached copy if it detects that the deriving DataSource has changed. Thus, if you change the metadata your DataSource is deriving (if, for example, you add a column to a table), all you need to do is touch the
.ds.xml
file (ie, update its last changed timestamp - you don't actually have to change it) and the cached copy will be refreshed next time it is needed.When autoDeriveSchema is set, SQLDataSource will automatically discover foreignKeys and deliver table and column name information to the client in hashed form so that two DataSources that are linked by native SQL foreign keys will automatically discover each other if loaded into the same application, and set
foreignKey
automatically. Because the table and column names are delivered as cryptohashes, there is no information leakage, but regardless, the feature can be disabled via settingdatasource.autoLinkFKs
to false inserver.properties
. This hashed linkage information is delivered to the client in propertiestableCode
andDataSourceField.fkTableCode
/fkColumnCode
Default value is null
- For a DataSource with serverType: "sql", automatically derive the dataSource's schema
from the Spring bean or Java class specified in
-
serverConfig
Configuration settings that will be used purely on the the server-side. Any properties declared within aserverConfig
block will be overlaid onto the regular dataSource configuration, such that any property declared inserverConfig
takes priority, but only on the server; the client never sees theserverConfig
block.serverConfig
is primarily intended for use with theRestConnector
, and is used for two related purposes. Firstly, it is a mechanism for declaring properties that only the server should see, to avoid information leakage to the client. Typical usages of this type would be things likeheaders
andparams
- things that are specific torestConnector
's communication with the remote REST server, and no business of the client's.Secondly,
serverConfig
is used in cases where you need the client and server to use different values for a property. The only property for which this definitely arises isdataURL
(and thesame property on the OperationBinding
), becausedataURL
is used both on the client, to configure the endpoint for server requests, and byRestController
on the server to configure the target URL(s) for REST request(s). Thus, you should always specify adataURL
insideserverConfig
if it is intended for use on the server-side by aRestConnector
DataSource; failure to do so will cause the client to send itsDSRequest
s directly to the remote REST server, which obviously will not know how to handle them.Sub-objects will be merged such that properties declared in
serverConfig
replace the same properties declared in the regular sub-object, but properties that are missing in theserverConfig
remain in the merged sub-object. For example:<DataSource ... > <operationBindings> <operationBinding operationType="fetch" dataURL="specialIDACallURL" outputs="some,list,of,fields" /> <!-- the browser can see this, so this works for the extremely rare case that a DataSource should contact different versions of the IDACall servlet for different operations. The browser is also aware of the limited outputs --> </operationBindings> <serverConfig> <operationBindings> <operationBinding operationType="fetch" dataURL="restServiceURL" /> <!-- this is the actual URL of the REST service to contact from the server. The browser never sees this so its version of "dataURL" is retained. At the same time, the "outputs" from the browser-visible definition still apply, because the configs were merged --> </operationBindings> <serverConfig>
Default value is null
- See Also:
-
useSequences
For a DataSource withserverType:"sql"
, this flag indicates whether any fields oftype
"sequence" should be backed by a native database sequence (if the flag is true) or an auto-increment/identity column (if it is false). It is only applicable in cases where the database in use supports both approaches, and Smart GWT supports both strategies with that particular database. For most databases, even those that natively support either approach, Smart GWT uses one or the other, and this cannot be configured.Right now, the only supported database is Microsoft SQL Server. If you specify this flag on a non-SQL DataSource or if any database other than SQL Server is in use, the flag is simply ignored.
If not set, this flag defaults to the
server.properties
settingsql.{dbName}.use.sequences
, which in turn defaults to false.Default value is null
-
allowAdvancedCriteria
By default, all DataSources are assumed to be capable of handlingAdvancedCriteria
on fetch or filter type operations. This property may be set tofalse
to indicate that this dataSource does not support advancedCriteria. SeesupportsAdvancedCriteria()
for further information on this.NOTE: If you specify this property in a DataSource descriptor (
.ds.xml
file), it is enforced on the server. This means that if you run a request containing AdvancedCriteria against a DataSource that advertises itself asallowAdvancedCriteria:false
, it will be rejected.Default value is null
- See Also:
-
schema
This property only applies to the built-in SQL DataSource provided in Pro and better editions of Smart GWTDefines the name of the schema we use to qualify the
tableName
in generated SQL. If you do not provide this property, we will try to use the Smart GWT default schema for thisdbName
; you specify this for a givendbName
in yourserver.properties
file like this:sql.the_dbName.default.schema: myDefaultSchema
If there is no DataSource-specific schema and no Smart GWT default schema, table names will not be qualified in generated SQL, and thus the database default schema will be used. Support for multiple schemas (or schemata) varies quite significantly across the supported databases, as does the meaning of the phrase "default schema". In addition, some databases allow you to override the default schema in the JDBC connection URL, which is a preferable approach if all your tables are in the same (non-default) schema, because it makes the generated SQL simpler (no need to qualify every table)The following table provides information by product:
Product Notes DB2 Arbitrarily named schemas are supported. The default schema is named after the connecting user, though this can be overridden by specifying the "currentSchema" property on the JDBC connection URL DB2 for iSeries Arbitrarily named schemas are supported. "Schema" is synonymous with "library". The default schema depends on the setting of the "naming" connection property. When this is set to "sql", behavior is similar to other DB2 editions: the default schema is named after the connecting user, unless overridden by specifying a library name in the JDBC connection URL. When "naming" is set to "system", the schema of an unqualified table is resolved using a traditional search of the library list; the library list can be provided in the "libraries" property Firebird Firebird does not support the concept of schema at all - all "schema objects" like tables and indexes belong directly to the database. In addition, Firebird actively rejects qualified table names in queries as syntax errors; therefore, you should not set the schema
property for a DataSource that will be backed by a Firebird databaseHSQLDB Arbitrarily named schemas are supported. The default schema is auto-created when the database is created; by default it is called "PUBLIC", but can be renamed. It is not possible to set the default schema in the JDBC connection URL Informix Informix databases can be flagged as "ANSI mode" at creation time. ANSI-mode databases behave similarly to DB2 for schema support: arbitrarily named schemas are supported, and the default schema is the one named after the connected user. Non-ANSI databases have no real schema support at all. It is not possible to set the default schema in the JDBC connection URL with either type of database Microsoft SQL Server Prior to SQL Server 2005, schema support is similar to Oracle: "schema" is synonymous with "owner". As of SQL Server 2005, schema is supported as a separate concept, and a user's default schema can be configured (though it still defaults to a schema with the same name as the user). It is not possible to set the default schema in the JDBC connection URL MySQL MySQL does not have a separate concept of "schema"; it treats the terms "schema" and "database" interchangeably. In fact MySQL databases actually behave more like schemas, in that a connection to database X can refer to a table in database Y simply by qualifying the name in the query. Also, because schema and database are the same concept in MySQL, overriding the "default schema" is done implicitly when you specify which database to connect to in your JDBC connection URL Oracle Arbitrarily named schemas are not supported; in Oracle, "schema" is synonymous with "user", so each valid user in the database is associated implicitly with a schema of the same name, and there are no other schemas possible. It is possible to refer to tables in another user's schema (assuming you have the privileges to do so) by simply qualifying the table name. The default schema is always implied by the connecting user and cannot be overridden. Postgres Arbitrarily named schemas are supported. Rather than the concept of a "default schema", Postgres supports the idea of a search path of schemas, whereby unqualified table references cause a search of the list of schemas in order, and the first schema in the path is the "current" one for creation purposes. Unfortunately, there is no way to specify this search path on the JDBC connection URL, so the default schema comes from the user definition, ultimately defaulting to the default "public" schema Default value is null
-
nullIntegerValue
public int nullIntegerValueIfnoNullUpdates
is set, the value to use for any integer field that has a null value assigned on an update operation, and does not specify an explicitnullReplacementValue
.Default value is 0
- See Also:
-
noNullUpdates
com.smartgwt.client.docs.serverds.DataSourceField#nullReplacementValue
-
xmlTag
Applies to RestConnector dataSources (serverType
"rest") only, and is overridable per operationBinding (seeOperationBinding.xmlTag
).This property specifies the name of the enclosing tag when we are generating the XML block used to send context to a REST service where the
requestFormat
is "xml"Default value is null
- See Also:
-
audit
public boolean auditEnables saving of a log of changes to this DataSource in a second DataSource with the same fields, called the "audit DataSource". NOTE: this feature applies to Enterprise Edition only; for more information on edition-specific features, see http://smartclient.com/product.When auditing is enabled, every time a DSRequest modifies this DataSource, a Record is added to the audit DataSource that shows the record as it existed after the change was made (or for a "remove", the values of the record at the time of deletion). In addition, the audit DataSource has the following additional metadata fields:
-
"audit_operationType"
: type of the change ("update", "add" or "remove") -
"audit_modifier"
: username of the user that made the change. The username is determined in the same way that theDeclarative Security
subsystem determines the current user. -
"audit_changeTime"
: a field of type "datetime" recording the timestamp of the change -
"audit_revision"
: a field of type "sequence" recording a simple increasing integer value -
"audit_changedFields"
: a"multiple"
field of type "string". For "update" operations, records which fields have changed; otherwise, null
If any of the field names above collide with field names of the DataSource being audited, an integer suffix will also be added, starting with 2 (for example, "audit_modifier2", then "audit_modifier3", etc).
To omit a data field from the automatically generated audit DataSource, just set
DataSourceField.audit
to false. Audit can be disabled for a given DSRequest via the server-side APIDSRequest.setSkipAudit()
, or for a specific operation via theoperationBinding.skipAudit
setting.When viewing DataSources in the
DataSource Navigator
, a button will be shown at the top of a DataSource's section if it has an audit DataSource to let you conveniently open another section to view it.Note: The DataSource audit feature works only with single row operations; operations with
allowMultiUpdate
enabled are not supported.Auto-generated Audit DataSources
The audit DataSource is normally automatically generated, and unless otherwise specified with
auditDataSourceID
, the ID of the audit DataSource will beaudit_[OriginalDSID]
.By default, the automatically generated audit DataSource will be of the same type as the DataSource being audited, however, if the DataSource being audited is not already a SQLDataSource, we recommend using
auditDSConstructor:"sql"
to use a SQLDataSource as the audit DataSource. This is because a SQLDataSource used an audit DataSource will automatically generate a SQL table for storing audit data the first time changes are made. JPA would require manual creation of a Java Bean, and Hibernate requires hbm2ddl.auto=update to be set, which is widely considered unsafe for production use.Note that the automatically generated audit DataSource may have additional fields that can be populated when new audit data is added. See
addedAuditFields
for more details.Automatically created audit DataSources can be loaded and queried just like other DataSources, using the DataSourceLoader, and using the server-side API
DataSource.getAuditDataSource()
. However, you must load the DataSource being audited before loading its automatically created audit DataSource.Note, that automatic SQL tables creation can be disabled. See
autoCreateAuditTable
for details.Connecting custom "Users" DataSource to auto-generated Audit DataSources
Audit DataSources utilize authenticated username (see the docs for
RPCManager.getUserId()
server-side API) to populate the "audit_modifier" field. To enable quick access to additional user information, you can associate them with a custom "Users" DataSource.This association can be configured via the framework setting "userDataSource.foreignKey" in the "server.properties" file, which establishes a relationship between authenticated user and your custom "Users" DataSource. Declaring this informs the system that the authenticated username is a valid ID for records within a specific "Users" DataSource. Use the regular
DataSourceField.foreignKey
format, where, in example below, "UserDS" represents the name of the related "Users" DataSource, and "userName" serves as the primary key of that DataSource:userDataSource.foreignKey: UserDS.userName
This configuration enables you to access additional user information seamlessly through built-in framework features likeDSRequest.additionalOutputs
andListGridField.includeFrom
when reviewing audit data. For instance, if "UserDS" declares fields such as "firstName" and "lastName," you can retrieve them using additional listGridFields:{name: "userFirstName", includeFrom: "UserDS.firstName"}, {name: "userLastName", includeFrom: "UserDS.lastName"}
Alternatively, if you're fetching data manually, you can utilize additionalOutputs as follows:additionalOutputs: "userFirstName!UserDS.firstName,userLastName!UserDS.lastName"
Manually created Audit DataSources
The audit DataSource can also be manually created. In this case, you can can either follow the naming conventions described above for the ID of the audit DataSource and the names of metadata fields, or use the linked properties to assign custom names. If you omit any data fields from the tracked DataSource in your audit DataSource, those fields will be ignored for auditing purposes, exactly as though
DataSourceField.audit
had been set to false for an automatically-generated audit DataSource.Also, note that in case of manually defined audit DataSource, if this DataSource is defined so it inherits the audited DataSource, all the audited DataSource's fields will be inherited, this including the primary keys. Since for the audit DataSource the primary key should be the revision field, in order to prevent the audit DataSource having two primary keys, the inherited DataSource's primary key will have to be declared in audit DataSource, but with the primaryKey attribute omitted (as well not being of type "sequence") in the audit DataSource.
Default value is false
- See Also:
-
-
resultTreeClass
Class for ResultTrees used by this datasource. If null, defaults to usingResultTree
.This can be set to a custom subclass of ResultTree that, for example, hangs on to extra information necessary for integration with web services.
Default value is null
-
guestUserId
Value to use for theownerIdField
if no one has authenticated.This setting can be overridden at the operationBinding level.
Default value is null
-
autoCreateAuditTable
public boolean autoCreateAuditTableSettingautoCreateAuditTable
totrue
indicates that audit DataSource will automatically create SQL table whenauditing
is enabled.Note, that
autoCreateAuditTable
attribute takes effect only if framework settingaudit.autoCreateTables
inserver.properties
is set tofalse
, which by default is set totrue
.Default value is true
-
headers
Applies to RestConnector dataSources (serverType
"rest") only, and is overridable per operationBinding (seeOperationBinding.headers
).Some REST servers require special HTTP headers to be sent to provide state or authentication details; this property can be used to set up one or more headers to be sent with the REST request. Like other elements of RestConnector config, you typically define this property inside a
serverConfig
block to keep the details from leaking to clients. Also like other RestConnector config, you can include Velocity templates in your header definitions.Headers are simple key/value pairs, defined like this:
<headers> <My-Custom-Header>Some custom value</My-Custom-Header> <Another-Special-Header>$config['special.header.value']</Another-Special-Header> </headers>
Note, we automatically add a "Content-Type" header of eitherapplication/json
orapplication/xml
(depending on theresponseFormat
), unless you define one by hand in your DataSource'sheaders
definitionDefault value is null
- See Also:
-
serverOnly
Setting a DataSource to beserverOnly="true"
ensures that it will not be visible to the client. Any request through IDACall to this DataSource will return a failure response. Only requests which have been initiated on the server-side will be executed against this DataSource.Default value is null
-
multiInsertStrategy
For dataSources ofserverType
"sql" only, this property sets the multi-insert strategy for add requests on thisdataSource
. Only has an effect if theadd request
specifies a list of records as the data. See the docs forMultiInsertStrategy
for more information.Note that this setting (along with the other multi-insert properties,
multiInsertBatchSize
andmultiInsertNonMatchingStrategy
) can be overridden at theoperationBinding level
and thedsRequest level
. If you wish to configure multi-insert setting globally, you can add the following properties to yourserver.properties
file:sql.multi.insert.strategy
Global equivalent ofmultiInsertStrategy
sql.multi.insert.batchSize
Global equivalent ofmultiInsertBatchSize
sql.multi.insert.non.matching.strategy
Global equivalent ofmultiInsertNonMatchingStrategy
Example
server.properties
settings:sql.multi.insert.strategy: multipleValues sql.multi.insert.batchSize: 300 sql.multi.insert.non.matching.strategy: dropMissing
See the "Batch inserting" paragraph of theaddData() documentation
for a description of the multi-insert implementation.Default value is "simple"
-
description
An optional description of the DataSource's content. Not automatically exposed on any component, but useful for developer documentation, and as such is included on anyOpenAPI specification
generated by the framework. Markdown is a commonly used syntax, but you may also embed HTML content in a CDATA tag.Default value is null
-
requiresRole
Similar toOperationBinding.requiresRole
, but controls access to the DataSource as a whole.Default value is null
- See Also:
-
compareMetadataForAuditChangeStatus
public boolean compareMetadataForAuditChangeStatusOnly applicable tobinary fields
onaudited
DataSources.When determining if a binary field has changed for auditing purposes, should we compare the metadata values (ie, the associated
_filename
and_filesize
fields) or the actual binary content? If you set this flag to false, this will cause Smart GWT to fetch the existing content of any binary field from the database before any update, and then compare it byte by byte to the new content. You should consider if this will have performance implications for your application, particularly if you store large binary values.Note that value comparison of any kind is only performed if the field's
DataSourceField.audit
setting is "change", but also note that this is the default setting for binary fieldsDefault value is true
-
quoteColumnNames
If set, tells the SQL engine to quote column names in all generated DML and DDL statements for this dataSource. This will ensure that queries generated against tables that do not follow the database product's natural column-naming conventions will still work.In general we recommend that you allow the database to use its natural naming scheme when creating tables (put more simply, just do not quote column names in the
CREATE TABLE
statement); if you do this, you will not need to worry about quoting column names when querying. However, if you are dealing with pre-existing tables, or do not have control over the database naming conventions used, this property may become necessary. This property may also be necessary if you are using field/column names that clash with reserved words in the underlying database (these vary by database, but a field called "date" or "timestamp" would have problems with most database products)Note: Only applicable to dataSources of
serverType
"sql".Default value is null
-
fileFormatField
The native field name used by this DataSource on the server to represent thefileFormat
forFileSource Operations
.If the fileFormatField is not configured, then a field named "fileFormat" will be used, if it exists. Otherwise, the DataSource will not track fileFormats -- this may be acceptable if, for instance, the fileFormat is always the same.
The fileFormat is specified according to the extension that would have been used in the filesystem -- for instance, the fileFormat for employees.ds.xml would be "xml".
Default value is null
- See Also:
-
trimMilliseconds
For this dataSource, should the millisecond portion of time and datetime values be trimmed off before before being sent from client to server or vice versa. By default, millisecond information is preserved (ie, it is not trimmed). You only need to consider trimming millisecond values if their presence causes a problem - for example, a custom server that is not expecting that extra information and so fails parsing.Note that there is no inherent support for millisecond precision in Smart GWT widgets; if you need millisecond-precise visibility and editability of values in your client, you must write custom formatters and editors (or sponsor the addition of such things to the framework). Server-side, millisecond-precise values are delivered to and obtained from DataSources, so DataSource implementations that are capable of persisting and reading millisecond values should work transparently. Of the built-in DataSource types, the JPA and Hibernate DataSources will transparently handle millisecond-precise values as long as the underlying database supports millisecond precision, and the underlying column is of an appropriate type. The SQLDataSource provides accuracy to the nearest second by default; you can switch on millisecond precision per-field with the
storeMilliseconds
attribute.Default value is null
-
requestProperties
Additional properties to pass through to theDSRequest
s made by this DataSource. This must be set before anyDSRequest
s are issued and before any component is bound to the DataSource.These properties are applied before
transformRequest()
is called.Default value is null
-
auditTypeFieldName
For DataSources withauditing enabled
, specifies the field name used to store theoperationType
(in a field of type "text"). If empty string is specified as the field name, the audit DataSource will not store this field.Default value is "audit_operationType"
-
tableCode
Only applicable to the built-in SQL DataSourcetableCode
and the related propertiesDataSourceField.columnCode
,DataSourceField.fkTableCode
andDataSourceField.fkColumnCode
are read-only attributes that are secure and unique cryptographic hashes of table and column names used by this DataSource.These properties are used automatically by client-side framework code to link dataSources together by
foreign key
when aforeignKey
is not explicitly declared, but is found in the SQL schema via theautoDeriveSchema
feature.A secure hash is used rather than the actual SQL table or column name for security reasons - sending the actual SQL table or column name to the client could aid in attempted SQL injection attacks.
This feature can be disabled system-wide via setting
datasource.autoLinkFKs
tofalse
inserver.properties
.Default value is null
-
arrayCriteriaForceExact
With ordinarysimple criteria
, it is possible to provide an array of values for a given field, which means "any of these values". For example:var criteria = { field1 : "value1", field2 : ["value2", "value3"] }
At first glance, this criteria appears to mean "select records where 'field1' is 'value1' and 'field2' is one of 'value2' or 'value3'". However, if the prevailingtextMatchStyle
is "substring" - as it would be if, for example, you had issued afilterData()
call - then this criteria means "select records where 'field1' contains 'value1' somewhere, and 'field2' contains either 'value2' or 'value3'"Depending on your requirement, this may or may not be what you want, and you can control it by setting the
textMatchStyle
on yourDSRequest
, or by setting a defaulttextMatchStyle
on the DataSource (defaultTextMatchStyle
), or by specifying that thetextMatchStyle
should be ignored for certain fields (DataSourceField.ignoreTextMatchStyle
)However, a common use case is that you want "substring" style filtering on one or more single-valued fields, but exact matching on a list-valued field. For example, say you want a list of customers based in certain cities, with a name matching the substring "software":
var criteria = { name : "software", city : ["York", "Newport", "Orleans"] }
Here, using substring matching on the "city" field is likely to give incorrect results, as it will match a number of US cities in addition to the three European cities intended (New York, Yorktown, New Orleans, Newport News, and probably others). And even if this is not an issue for your particular use case, and correct results can be obtained with a substring search, it is very likely to be more costly performance-wise than the exact value match that you really need (potentially much more costly).You could achieve exact matching in the above case by marking the "city" field as
ignoreTextMatchStyle:true
, but that would mean you couldn't perform substring searches on that field in other use cases where that might be desirable.In cases like this, Smart GWT by default treats list-valued simple criteria as if
ignoreTextMatchStyle
is in force for that field. If you want to switch this behavior off, and have list-valued simple criteria handled with the prevailingtextMatchStyle
, setarrayCriteriaForceExact
to false. It is also possible to set this flag per-operationBinding and per-DSRequest - seeOperationBinding.arrayCriteriaForceExact
andDSRequest.arrayCriteriaForceExact
If you want to switch this behavior off across the entire system, set the flag in your
server.properties
file:arrayCriteriaForceExact: false
This will only have an effect for server-side DataSources; if you want to change this flag globally forclientOnly
dataSources, change the default in the client-sideDataSource
class, like so:isc.DataSource.addProperties({arrayCriteriaForceExact: false});
If you do change the global defaults, it is still possible to override per-dataSource or per-operationBinding, as described above.Note, all of this only applies to simple criteria. If your dataSource
supports AdvancedCriteria
, that gives you much finer and more complete control over the exact meaning of individual criterions.Default value is null
- See Also:
-
auditChangedFieldsFieldLength
For DataSources withauditing enabled
, specifies the length of the field used to store the names of the fields which were updated. See alsoauditChangedFieldsFieldName
To set the changedFields field length for all DataSources that do not override the default, set
audit.auditChangedFieldsFieldLength
in yourserver.properties
file. For exampleaudit.auditChangedFieldsFieldLength: 512
Default value is 255
-
auth
For aRestConnector DataSource
, authentication details for the REST service. Note, although RestConnector-specific details would typically be wrapped in aserverConfig block
to prevent information leakage to the client, we automatically exclude theauth
block even if it is not insideserverConfig
, because this is information that is always sensitive, and never required on the clientDefault value is null
- See Also:
-
inheritanceMode
For dataSources ofserverType
"sql" and "hibernate", specifies the inheritance mode to use. This property has no effect for any other type of DataSource.Default value is "full"
- See Also:
-
nullFloatValue
public float nullFloatValueIfnoNullUpdates
is set, the value to use for any float field that has a null value assigned on an update operation, and does not specify an explicitnullReplacementValue
.Default value is 0.0
- See Also:
-
noNullUpdates
com.smartgwt.client.docs.serverds.DataSourceField#nullReplacementValue
-
schemaNamespace
For a DataSource derived from WSDL or XML schema, the XML namespace this schema belongs to. This is a read-only attribute automatically present on DataSources returned from SchemaSet.getSchema() andWebService.getSchema()
.Default value is null
- See Also:
-
qualifyColumnNames
For dataSources ofserverType
"sql", determines whether we qualify column names with table names in any SQL we generate. This property can be overridden on specific operationBindings.Default value is true
- See Also:
-
auditRevisionFieldName
For DataSources withauditing enabled
, specifies the field name used to store the revision number for the change (in a field of type "sequence"). If empty string is specified as the field name, the audit DataSource will not store this field.Default value is "audit_revision"
-
dataURL
Default URL to contact to fulfill all DSRequests. Can also be set on a per-operationType basis viaOperationBinding.dataURL
.NOTE: Best practice is to use the same
dataURL
for all DataSources which fulfill DSRequests via the server-side RPCManager API. Otherwise, cross-DataSourceoperation queuing
will not be possible.dataURL and
RestConnector
dataURL
is also used to configure the address of the target REST server for aRestConnector
DataSource. Typically this is done at theoperationBinding level
, because the URLs of REST services often encode things about the service itself, like whether it is a fetch or an update. However, if your REST service does use the same URL for every service, or most services, you can configure it here at the DataSource level.As discussed in the
RestConnector overview
, many elements ofRestConnector
config can be Velocity templates, anddataURL
is one such element. For example:<operationBinding operationType="fetch" operationId="fetchByPK"> <dataURL>$config['rest.server.base.url']/fetch/$criteria.pk</dataURL> </operationBinding>
NOTE: Because the server-sideRestConnector
implementation uses thedataURL
property to configure the address of the target REST server, and that property also has meaning on the client, if you are using aRestConnector
DataSource, you should specify thedataURL
of the target REST server inside theserverConfig
blockDefault value is null
- See Also:
-
jsonPrefix
Allows you to specify an arbitrary prefix string to apply to all json format responses sent from the server to this application.The inclusion of such a prefix ensures your code is not directly executable outside of your application, as a preventative measure against javascript hijacking.
Only applies to responses formatted as json objects. Does not apply to responses returned via scriptInclude type transport.
Note: If the prefix / suffix served by your backend is not a constant, you can usedataFormat:"custom"
instead and explicitly parse the prefix out as part oftransformResponse()
.Default value is null
-
projectFileLocations
For DataSources with type
, specifies locations for the project files. In XML, each location is expressed with aprojectFile
<location>
tag, e.g.:<projectFileLocations> <location>[WEBROOT]/shared/ds</location> <location>ds://datasources</location> </projectFileLocations>
Directories should be specified as absolute paths on the server. If you want to construct a webroot-relative path, then prefix the path with[WEBROOT]
(unlike inserver.properties
, where you would use$webRoot
as the prefix).To specify another DataSource to be used via
fileSource operations
, useds://dsName
(where "dsName" is the name of the other DataSource).A
projectFile
DataSource uses the standardfileSource
field names:fileName
,fileType
,fileFormat
,fileContents
,fileSize
andfileLastModified
. When defining aprojectFile
DataSource, you can useinheritsFrom
with a value of "ProjectFile" to inherit definitions for these fields -- e.g.:<DataSource ID="MyDataSources" type="projectFile" inheritsFrom="ProjectFile"> <projectFileLocations> <location>[WEBROOT]/shared/ds</location> <location>ds://datasources</location> </projectFileLocations> </DataSource>
For directory locations, the
fileName
is relative to the directory specified. Note that thefileName
does not include any extension for type or format. For instance, for "employees.ds.xml", thefileName
would be "employees", thefileType
would be "ds" and thefileFormat
would be "xml".A projectFile DataSource executes the various
fileSource operations
in the following manner. The general rule is thatfileName
,fileType
, andfileFormat
are treated as primary keys. If files with the same combination of those attributes exist in more than one of the configured locations, the locations are considered in reverse order, with priority given to the location listed last. When modifying an existing file, the last location which contains the file will be used. When creating a new file, the file will be created in the last configured location.listFiles
- Returns a combined list of files from
all configured locations. Note that
listFiles
does not recurse into subdirectories. If the same combination offileName / fileType / fileFormat
exists in more than one configured location, then the data forfileSize
andfileLastModified
will be taken from the last configured location which contains the file. hasFile
- Indicates whether the file exists in any of the configured locations.
getFile
- Returns file data by searching the locations in reverse order.
saveFile
- If the file exists, it will be saved in the last location in which it exists. If it is a new file, it will be saved in the last configured location.
renameFile
- The file will be renamed in the last location in which it exists.
Note that if the file exists in more than one location, the rename
will not affect other locations. Thus, a subsequent
listFiles
operation will return the file from the other location (as well as the renamed file). removeFile
- The file will be removed from the last location in which it exists.
Note that if the file exists in more than one location, the removal
will not affect other locations. Thus, a subsequent
listFiles
operation will return the file from the other location.
projectFile
DataSource also responds to the standard DataSource operations, in the following manner:- add
- Executes a
saveFile
operation, either adding the file or updating an existing file. - fetch
- Executes a
listFiles
operation. Note that the results will not include thefileContents
. In order to obtain thefileContents
, you must use agetFile operation
. - update
- Executes a
renameFile
operation. Note that this will not update thefileContents
-- for that, you need to use "add", or asaveFile operation
. - remove
- Executes a
removeFile
operation.
If you specify both
projectFileKey
andprojectFileLocations
, then both with be used, with theprojectFileLocations
applied last.Default value is null
- See Also:
-
allowCriteriaSubqueries
Controls whetherAdvancedCriteria subqueries
are permitted for thisDataSource
. Set this valuetrue
to always permit subqueries in criteria on this dataSource, and set it false to always disallow them.The default value of null means that we use the global setting, controlled by setting the
allowCriteriaSubqueries
flag in yourserver.properties
file (this global flag is true by default))Default value is null
- See Also:
-
ownerIdField
Requires that the currently authenticated user match the contents of this field, for client-initiated requests (i.e., whereDSRequest.isClientRequest()
returns true on the server).Note, the behaviors described below can be affected by the dataSource properties
ownerIdNullRole
andownerIdNullAccess
, so please read the documentation for those two properties in conjunction with this article.When a new row is added by a client-initiated
DSRequest
, the ownerIdField will be automatically populated with the currently authenticated user (clobbering any value supplied by the client). Client-initiated attempts to update the ownerIdField will also be prevented.If you wish to set the ownerIdField to a different value via an "add" or "update" operation, you can do so in server-side DMI code (possibly consulting
DSRequest.getClientSuppliedValues()
to get the value that was clobbered).For client-initiated "fetch", "update" or "remove" operations, the server will modify client-supplied criteria so that only rows whose ownerIdField matches the currently authenticated user can be read, updated or deleted. For built-in DataSource types (SQL, Hibernate and JPA), the additional criteria required to match the
ownerIdField
field will ignore the prevailingtextMatchStyle
and always use exact equality. If you have a custom or generic DataSource implementation, you will want to do the same thing, to avoid false positives on partial matches (eg, a user with name "a" gets records where the owner is any user with an "a" in the name). You can determine when this is necessary by looking for aDSRequest
attribute called "restrictedOwnerIdField". For example, code similar to the following:String restrictedField = (String)dsRequest.getAttribute("restrictedOwnerIdField"); if (field.getName() != null && field.getName().equals(restrictedField)) { // Use exact matching for this field } else { OK to use the textMatchStyle }
Also note, for server-initiated requests, this automatic criteria-narrowing is not applied; if your application requires server-initiated "fetch", "update" and "remove" requests to be limited to the currently-authenticated user, your code must add the necessary criteria to the request.The ownerIdField setting can be overridden at the
OperationBinding.ownerIdField
level.If ownerIdField is specified,
requiresAuthentication
will default totrue
. IfrequiresAuthentication
is explicitly set tofalse
, then unauthenticated users will be able to see all records. To avoid this, you can useguestUserId
to specify a default user to apply when no one has authenticated.Default value is null
- See Also:
-
lookAhead
public int lookAheadIf we areloading progressively
, indicates the number of extra records Smart GWT Server will read beyond the end record requested by the client, in order to establish if there are more records to view. This property has no effect if we are not progressive-loading.This property can be tweaked in conjunction with
endGap
to change behavior at the end of a dataset. For example, with the default values oflookAhead: 1
andendGap: 20
, we can end up with the viewport shrinking if we get a case where there really was only one more record (because the client was initially told there were 20 more). This is not a problem per se, but it may be surprising to the user. You could prevent this happening (at the cost of larger reads) by settinglookAhead
to beendGap+1
.Default value is 1
- See Also:
-
childrenField
fieldName for a field in the dataSource expected to contain an explicit array of child nodes. Enables loading a databound tree as a hierarchical data structure, rather than a flat list of nodes linked by foreignKey.
Note this is an alternative to settingDataSourceField.childrenProperty
directly on the childrenField object.By default the children field will be assumed to be
multiple
, for XML databinding. This implies that child data should be delivered in the format:<childrenFieldName> <item name="firstChild" ...> <item name="secondChild" ...> </childrenFieldName>
However data may also be delivered as a direct list ofchildrenFieldName
elements:<childrenFieldName name="firstChild" ...> <childrenFieldName name="secondChild" ...>
If you want to return your data in this format, you will need to explicitly setmultiple
to false in the appropriate dataSource field definition.Default value is null
- See Also:
-
httpMethod
Applies to RestConnector dataSources (serverType
"rest") only, and is overridable per operationBinding (seeOperationBinding.httpMethod
).Allows you to configure the HTTP method to use for this DataSource. Since REST services typically use different HTTP methods for different types of operation - it is common to use GET for fetches and PUT for updates, for example - this property is more commonly set at the
operationBinding level
than at the DataSource level. See this Mozilla article for a list of valid HTTP methods.If this property is not provided at either DataSource or opBinding level,
RestConnector
uses a default HTTP method depending on the type of operation:Operation type HTTP Method Fetch GET Add POST Update PUT Remove DELETE Default value is null
- See Also:
-
inheritsFrom
ID of another DataSource this DataSource inherits itsfields
from.Local fields (fields defined in this DataSource) are added to inherited fields to form the full set of fields. Fields with the same name are merged in the same way that
databound component fields
are merged with DataSource fields.The default order of the combined fields is new local fields first (including any fields present in the parent DataSource which the local DataSource re-declares), then parent fields. You can set
useParentFieldOrder
to instead use the parent's field order, with new local fields appearing last. You can setshowLocalFieldsOnly
to have all non-local fields hidden.Note that only fields are inherited - other properties such as dataURL and dataFormat are not. You can use ordinary inheritance, that is, creating a subclass of DataSource, in order to share properties such as dataURL across a series of DataSources that also inherit fields from each other via
inheritsFrom
.This feature can be used for:
- creating a customized view (eg, only certain fields shown)
which will be used by multiple
databound components
. - adding presentation-specific attributes to metadata that has been
automatically derived from
XML Schema
or other metadata formats - modeling object subclassing and extension in server-side code and storage systems
- modeling relational database joins, and the equivalents in other systems
- creating hooks for others to customize your application in a maintainable way. For
example, if you have a dataSource "employee", you can create a dataSource "customizedEmployee"
which inherits from "employee" but does not initially define any fields, and bind all
databound components
to "customizedEmployee". Customizations of fields (including appearance changes, field order, new fields, hiding of fields, and custom validation rules) can be added to "customizedEmployee", so that they are kept separately from the original field data and have the best possible chance of working with future versions of the "employee" dataSource.
Default value is null
- creating a customized view (eg, only certain fields shown)
which will be used by multiple
-
wrapInList
Applies to RestConnector dataSources (serverType
"rest") only, and is overridable per operationBinding (seeOperationBinding.wrapInList
).When true, and the
requestFormat
is "json", and thedsRequest
only contains a single valueSet, we will wrap that single valueSet in a list before sending to the remote REST server. This is useful if you have a remote service that wants data to be supplied as a list, even when there is only one entry in the listDefault value is false
- See Also:
-
auditedDataSourceID
For audit DataSources, this required property specifies the ID of theaudited
DataSource. Automatically populated forauto-generated
audit DataSources.Default value is varies
-
nullBooleanValue
public boolean nullBooleanValueIfnoNullUpdates
is set, the value to use for any boolean field that has a null value assigned on an update operation, and does not specify an explicitnullReplacementValue
.Default value is false
- See Also:
-
noNullUpdates
com.smartgwt.client.docs.serverds.DataSourceField#nullReplacementValue
-
nullDateValue
IfnoNullUpdates
is set, the value to use for any date or time field that has a null value assigned on an update operation, and does not specify an explicitnullReplacementValue
.Unlike strings and numbers, there is no "natural" choice for a null replacement value for dates. The default value we have chosen is midnight on January 1st 1970, simply because this is "the epoch" - the value that is returned by calling "new Date(0)"
Default value is See below
- See Also:
-
noNullUpdates
com.smartgwt.client.docs.serverds.DataSourceField#nullReplacementValue
-
dataField
Name of the field that has the most pertinent numeric, date, or enum value, for use when aDataBoundComponent
needs to show a short summary of a record.For example, for a DataSource of employees, good choices might be the "salary" field, "hire date" or "status" (active, vacation, on leave, etc).
Unlike
titleField
, dataField is not automatically determined in the absence of an explicit setting.Default value is null
-
-
Constructor Details
-
DataSource
public DataSource()
-