SmartGWT EE provides ultimate flexibility when if comes to server side DataSource integration. For this, you define
your datasource definition in an easy to follow XML format and place it web server (war). In this DataSource definition,
you not only declare the various field definitions, constraints and relationships, but also specify the connector type
for the DataSource in the "serverType" attribute.
- Relational DataSource Connector : For this you specify serverType="sql" and point to the database table name that maps
to the DataSource. DataSource's of this type can generate and execute queries against popular SQL engines, providing SmartClient's
DataBoundComponents with the four standard CRUD operations (create, retrieve, update, delete) without writing any server-side code.
For rapid prototyping, these DataSources can even generate SQL tables based on the DataSource declaration, using the Admin Console
visual tool.
-
Hibernate Connector (Prototyping) : Simply declaring a DataSource with serverType:"hibernate" enables you to automatically
generate tables, import sample data and perform all four DataSource operations. Behind the scenes a SmartGWT EE generates the
Hibernate mapping file (.hbm) from the datasource definition, generates the corresponding table and imports sample data specified in you
DataSource definition by the dbImportFileName attribute.
-
Direct Method Invocation (DMI) : You can have the various DataSource operations execute against your own server service object. You first specify
serverType="generic" in your DataSource definition. Now you have a several options for which object these DataSource operations execute on :
- Spring Bean : In your DataSource defintion you specify <serverObject lookupStyle="spring" bean="supplyItemDao"/>. Here
supplyItemDao is a Spring bean that has the methods fetch, add, update and remove declared. You have the option of mapping each operation to method
names of you choosing.
- New Instance of your class : In your DataSource definition you specify <serverObject lookupStyle="new" className="com.smartgwtee.sample.showcase.server.SupplyItemDMI"/>.
A new instance of the class specified will be created and the DMI method will be invoked on that instance (unless the specified method is static, in which case no instance is created,
but the class specified by ServerObject.className is still used).
-
FactoryYou specify serverObject lookupStyle="factory" where className specifies the className of the factory that will provide the instance on which
the DMI method is to be invoked. A custom factory provides the class instance on which the DMI method is to be invoked. The factory class must provide exactly
one method named create that must return the class instance on which you wish the DMI method to be invoked.
-
Objects in your web session. You specify serverObject lookupStyle="attribute" along with the attributeName, and the
attributeScope where the bean resides. attributeScope specifies the scope in which the DMI instance is to be looked up.
Valid values are: "request", "session", and "application". If attributeScope is left out of the definition, then all scopes are
searched in the order in which they are listed above.
Once the DMI methods are called, you are free to process the request using a method of your choice. For instance Hibernate is a popular ORM choice so you
can simply delegate these fetch, update, add and remove calls to Hibernate for processing.
-
Servlet Front Controller : You can have the datasource requests be issues to a given HTTP request like /supplyItemOperations.rpc or supplyItemOperations.do
and then map this request to your servlet front controller using Struts or Spring MVC. Once your Controller is hit, you can use the SmartGWT EE server classes
create server versions of RPCManager and DataSource to effectively read and extract the request operations and parameters in a typesafe manner. Similarly, you can use the
SmartGWT EE server classes to convert the bean data, or data in response to update, or remove operations to the desired format.