Google Web Toolkit(GWT)创建读取更新和删除(CRUD)应用程序的示例

你好
有没有人知道基于Google Web Took(GWT)的创建读取更新和删除应用程序的任何示例。
也就是说,使用GWT来操纵和显示数据库内容的应用程序。

谢谢

GWT是一种客户端技术,因此基本上只为您提供UI。 任何CRUD进程都会发生在服务器端,可能是任何J2EE代码。

无论如何,您可以查看StockWatcher示例 ,它为您提供了一个很好的方法来解决您的问题(您需要实现服务器端存储)

另请参阅RequestFactory文档

它对你有帮助吗?

在线没有太多这样的例子。 但这就是我通常这样做的方式:

让我们假设你想从数据库中获取某个表的所有内容:

  1. 在GreentingService.java中执行以下操作:

    public interface GreentingServiceextends RemoteService {ArrayList getEverything(); }

  2. 在GreentingServiceSync.java中执行以下操作:

    public interface GreentingService {void getEverything(AsyncCallback callback); }

  3. 最后在GreentingServiceImpl中执行以下操作:

    public class GreentingServiceIMPL extends RemoteSericeServlet implments GreentingService { public ArrayList getEverything() { String query="Select * from...."; Class.forName("com.mysql.jdbc.Driver").newInstance(); Connection conn=DriverManager.getConnection(url,user,password); Statement stmt = conn.createStatement(); //get stuff out of daatabase here and retun as an arraylist } } 
  4. 这就是你如何调用这个方法并使用数据:public Someclass实现了EntryPoint {public void onModuleload(){SQLRunnerAsync sql =(SQLRunnerAsync)GWT.create(SQLRunner.class); AsyncCallback> callback = new AsyncCallback>(){

      @Override public void onFailure(Throwable caught) { //do nothing } @Override public void onSuccess(ArrayList result) { for(int i = 0; i < result.size(); i++) { } }}; sql.getEverything(callback); 

    ...............} // onModulelOad} //类

以下是一个很棒的教程: http : //altair.cs.oswego.edu/~tenberge/tenbergen.org/misc/DB-Access-in-GWT-The-Missing-Tutorial.pdf

这是一个骨架CRUD应用程序,我这对于寻找同一问题的答案的人会有所帮助

http://code.google.com/p/gwtcrudapp/

这是一个基于网络的CRUD应用程序,我在过去几年里为我的雇主写过,现在获得开源许可:

https://github.com/fhcampuswien/atom

它使用GWT作为前端,Hibernate将数据保存在后端。 数据结构只需要在一个中心位置(DomainObject类)定义,因为GUI和后端都是以不依赖于数据结构的通用方式编写的。

如果有人有时间去看看,我很乐意听到评论或回答有关它的问题。