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 badges5 Answers
Reset to default 7My 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.