最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - What is the best way to use Ext JS as part of JavaSpringHibernate based web application? - Stack Overflow

programmeradmin5浏览0评论

We want to try Ext JS on new project. Is there any well-known best practice for integrating Ext JS with server side Java (Spring/Hibernate/JS) application? Is DWR a good choice for that?

We want to try Ext JS on new project. Is there any well-known best practice for integrating Ext JS with server side Java (Spring/Hibernate/JS) application? Is DWR a good choice for that?

Share Improve this question edited May 23, 2010 at 16:18 Brian Moeskau 20.4k8 gold badges72 silver badges74 bronze badges asked Sep 16, 2008 at 9:42 Igor RomanovIgor Romanov 1,7172 gold badges20 silver badges36 bronze badges
Add a ment  | 

5 Answers 5

Reset to default 7

My team has been using Ext with DWR for almost year a year, and have had nothing but good things to say. If you take this approach, you will end up using DWR's generated JavaScript classes for making your requests to the server. This will often be done in place of using the Ext.Ajax and Ext.data.Connection classes. When you use a class that require an Ext.data.Store (e.g. grip, bo box, etc.) and you want to fetch data from the server, you will need to use a proxy that can link in with DWR. The user-munity provided Ext.ux.data.DWRProxy has worked flawlessly for us: http://extjs./forum/showthread.php?t=23884.

Yes it's possible.

I've done the same thing with .NET : UI in ext-JS which municates with the server trough JSON. In .NET world you can use DataContractSerializer (class from WCF) or JavascriptSerializer (ASP.NET)

I'm sure that there's several good JSON Serializer in the Java world too. I used Jabsorb (but not enough to give you a solid feedback). It appears that other people have tried : [link text][2]

[2]: http://extjs./forum/showthread.php?t=30759 forum ext-js

In our application we subclass Ext.data.DataProxy like this:

var MyProxy = function(fn) {
  this.fn = fn;
};
Ext.extend( MyProxy, Ext.data.DataProxy, {
  load: function(params,reader,callback,scope,arg) {
    this.fn(params,function(data) {
      callback.call(scope,reader.readRecords(data),arg,true);
    });
  },
  update: function() {}
});

You use it with a store like so:

var store = new Ext.data.Store({
  reader: myReader, proxy: new MyProxy(function(params,callback) {
    // params are used for paging and searching, if you need it
    callback(SomeService.getData(params));
  })
  // ...
});

Our actual proxy class has some additional debug and error handling code that I left out for simplicity. You may also need to manipulate your data slightly so that the Ext.data.JsonReader can handle it, but that's the basic idea. SomeService is the JavaScript name you specified for whatever bean you exposed in dwr.xml (or your Spring config).

Take a look at Grails, it plays well together with ExtJS.

It's perfectly fine to build your application using Ext JS/DWR/Spring/Hibernate.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论