【问题标题】:An example of a Google Web Toolkit (GWT) Create Read Update and Delete (CRUD) ApplicationGoogle Web Toolkit (GWT) 创建读取更新和删除 (CRUD) 应用程序示例
【发布时间】:2010-10-31 18:19:17
【问题描述】:

你好
有谁知道基于 Google Web Take (GWT) 的创建读取更新和删除应用程序的任何示例。
即,使用 GWT 来操作和显示数据库内容的应用程序。

谢谢

【问题讨论】:

    标签: java gwt crud


    【解决方案1】:

    网上这样的例子不多。 但这是我通常的做法:

    假设您想从数据库中获取某个表的所有内容:

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

      公共接口GreentingServiceextends RemoteService { ArrayList getEverything(); }

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

      公共接口GreentingService { void getEverything(AsyncCallback 回调); }

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

         public class GreentingServiceIMPL extends RemoteSericeServlet implments GreentingService
         {
           public ArrayList<String> 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. 这是调用此方法和使用数据的方式: 公共 Someclass 实现入口点 { 公共无效 onModuleload() { SQLRunnerAsync sql = (SQLRunnerAsync) GWT.create(SQLRunner.class); AsyncCallback> 回调 = 新的 AsyncCallback>(){

          @Override
          public void onFailure(Throwable caught) {
              //do nothing
      
          }
      
          @Override
          public void onSuccess(ArrayList<String> 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

    【讨论】:

      【解决方案2】:

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

      无论如何,您都可以查看StockWatcher Example,它可以很好地解决您的问题(您需要实现服务器端存储)

      还可以查看RequestFactory 文档

      对你有帮助吗?

      【讨论】:

        【解决方案3】:

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

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

        【讨论】:

          【解决方案4】:

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

          https://github.com/fhcampuswien/atom

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

          如果有人有时间看一看,我很想听听 cmets 或回答有关它的问题。

          【讨论】:

            猜你喜欢
            • 2011-12-26
            • 2020-02-06
            • 1970-01-01
            • 1970-01-01
            • 2011-04-26
            • 1970-01-01
            • 2010-11-06
            • 2012-03-07
            • 2011-03-02
            相关资源
            最近更新 更多