当前位置:文档之家› Smart GWT简介

Smart GWT简介

Smart GWT简介
Smart GWT简介

Smart GWT简介

1.概览

用一句话来概括,Smart GWT 是封装了 SmartClient 的 GWT API。而 SmartClient 是一个开源的企业级 Ajax 开发框架。

Google Web Toolkit 的发布,大大降低了 Java 开发人员进行 Web 开发的门槛。然而 GWT 本身提供的控件及功能相对有限。因此出现了很多第三方开源扩展库。

总体来看,Smart GWT 有如下特色:

?丰富的控件。很多较为复杂的常用界面都被包装成简单易用的控件。比如可编辑的树形表格、查询创建器、支持分组交叉的Grid和图表、类似 Google Calendar 的日历等等。

?内置的数据整合功能。利用 SmartClient 的 MVC 模式,用户可以通过定义数据源(Data Source),很容易地开发出能对服务器端数据进行创建,更新,获取和删除操作的界面。甚至只要 10 行以内的代码。

?Smart GWT 企业版内置了对 JDBC 和 Hibernate 的支持,对这样的数据源,只需通过定制配置文件的方式即可动态的创建,大大简化了开发。而且数据源将界面组件和后台数据分隔开来,带来的好处是可以替换数据源而不改动任何客户端代码。

?支持 Skin。通过 Skin,用户能定制整套风格一致的界面方案。只需在线切换,就可以换到全新的风格。

2.特征点

1.Smart GWT可使用Java代替JavaScript开发Ext风格的界面,并使用GWT

编译生成运行时页面(Google提供的GWT Compile进行编译,在Eclipse中

进行编译可以安装其插件);

2.支持多元化的数据源:SQL、Hibernate、自定义Bean等;

3.在数据源配置中利用Spring上下文绑定注入的业务方法,提供对事务的支持;

4.封装了请求和响应,使用DMI机制实现对服务器端类及其方法的调用;

5.其扩展的客户端组件开发包(SmartClient SDK)种类丰富、功能强大,比较典

型的有:

●功能强大的Grid组件,支持表头过滤、行编辑、校验,锁定行、列等;

●方便实用的Tree及Tree Grid组件,支持拖拽维护树节点等;

●交叉分组报表的实现及运行时配置(表头表列自由组合、自动生成图表等);

●数据脱机以改善数据操作友好性,延迟加载提升海量数据展示时的速度;

●多种格式的数据导出、文件上传、动画、实时动态等。

6.提了实用的开发辅助工具:例如数据源管理控制台、批量数据源生成器,开发控制

台,界面配置器(SmartClient)等;

3、C/S结构简图

Server Request Flow(数据请求响应流程)

When using the Smart GWT server framework, DSRequests go through the following flow:

1. DSRequest serialization: requests from DataSources are automatically serialized and delivered to the server.

将客户端请求的数据进行序列化,发送到服务器端(GWT Server);

2. DSRequest parsing: requests are automatically parsed by a servlet included with the Smart GWT server framework, and become

com.isomorphic.datasource.DSRequest Java Objects.

服务器接受到请求后,对数据进行解析,得到DSRequest对象;

3. Authentication, validation, and role-based security checks are performed based on declarations in your DataSource descriptor (.ds.xml file). For example, requiresRole="manager".

认证、校验、角色授权等等操作将基于*.ds.xml文件中的配置声明进行;

4.DMI (Direct Method Invocation): custom Java logic can be run before or after the DataSource operation is performed, modifying the DSRequest or DSResponse objects, or can skip the DataSource operation and directly provide a DSResponse.

接收输入,加入并执行自定义的服务器端业务逻辑,加工输出,得到DSResponse对象;

5. Persistence operation: the validated DSRequest is passed to a DataSource for execution of the persistence operation. The DataSource can be one of several built-in DataSource types (such as SQL or Hibernate) or a custom type.

数据持久化;

6. The DSResponse is automatically serialized and delivered to the browser. 将DSResponse中的内容序列化并发送到客户端。

3.开发要点

--数据源的集成、绑定和加载

1. Create DataSource descriptors (.ds.xml files), specifying data model (metadata) properties in the DataSource fields.

创建数据源描述文件(.ds.xml),在该文件中配置数据源模型(元数据)的各项属性(字段)。

2. Back your DataSources with an actual data store. The Smart GWT Admin Console GUI can create and populate relational database tables for immediate use. Chapter 7, Data Integration, describes the integration points for binding to other object models and data stores.

借助数据源管理控制台(DataSource Admin Console)可以对数据提供者进行集成和管理,借助批量数据源生成器(Batch DataSouce Generator)可以批量生成*.ds.xml文件。

3. DMI (Direct Method Invocation) allows you to declare what Java class and method should be invoked when specific DSRequests arrive at the server. A DMI is declared by adding a tag to your DataSource descriptor.

同时,借助DMI机制对需要调用的服务器端方法进行配置,对默认的请求和响应操作(增删改查)进行重载。

4. Load DataSource descriptors in your Smart GWT-enabled pages using a standard