PDA

View Full Version : ExtJsWithDwr project on GitHub



loeppky
14 Jun 2009, 10:43 AM
The ExtJsWithDwr project has been announced on the Ext 2.x User Extensions and Plugins forums (http://extjs.com/forum/showthread.php?t=69349). As support has been added and checked in for Ext 3.x, I wanted to get a thread post started for Ext 3.x.

In this thread, I expect to see:

Questions about Ext.ux.data.DwrProxy
Bug reports for Ext.ux.data.DwrProxy
Ideas for additions to the ExtJsWithDwr project.


Relevant links:

ExtJsWithDwr project on GitHub (http://github.com/BigLep/ExtJsWithDwr)
ExtJsWithDwr user extension wiki (http://extjs.com/learn/Extension:ExtJsWithDwr)

loeppky
14 Jun 2009, 11:31 AM
An upgrade guide for moving from v2 -> v3 of Ext.ux.data.DwrProxy has been added here: http://github.com/BigLep/ExtJsWithDwr/blob/v3/UPGRADE.markdown.

Next up is to add support for the other CRUD operations within Ext.ux.data.DwrProxy (see http://github.com/BigLep/ExtJsWithDwr/issues/#issue/7).

loeppky
15 Jun 2009, 8:21 AM
Just a quick update that I made this change: http://github.com/BigLep/ExtJsWithDwr/commit/11caab02a5e8da2992db0887c00a1b2aab6392d5


Refactored DwrProxy so that it mirrors Ext.data.HttpProxy. The load method has been removed. This is a first step to make it easier to support additional CRUD methods, and to make one understand the proxy code easier as it's now more similar to Ext 3.x's proxies. The upgrade guide was also updated noting to not use the loadexception event or the load method as they have both been deprecated in Ext 3.x.

loeppky
1 Jul 2009, 8:07 PM
Just an update that I won't be able to work on the remaining CRUD methods for Ext.ux.data.DwrProxy. I have been oncall for the last weeks at work, which has chewed up my extra bandwidth. In addition, I have 16 family members coming to town for 2 weeks, at which time I'll be on vacation and disconnecting from the computer. I will resume working on improving/supporting DwrProxy then.

trnl
9 Aug 2009, 9:43 PM
hi, have you finished remaining CRUD methods ?

k_new
11 Aug 2009, 7:16 PM
Hi, I have problem in using the DWRProxy. I'm trying an example as below:

grid.js
..
..
..
var store = new Ext.data.ArrayStore({
fields: [
{name: 'id', type:'int'},
{name: 'description', type: 'string'},
{name: 'firste', mapping:"author.firstName", type: 'string'},
{name: 'last', mapping:"author.lastName", type: 'string'}
]
});

var myData = new Ext.data.Store({
proxy: new Ext.data.DWRProxy(TodoService.getItems, true),
reader: new Ext.data.ListRangeReader( {id:'id', totalProperty:'totalSize'}, recordType),
remoteSort: true
});
store.loadData(myData);
..
..
..

The DWRProxy was 1.x version. I tried to adapt to the dwr 3.0 & ext js 3.0, but it doesn't work. Error message shown: 'TodoService' is not defined.

What should I do?

trnl
12 Aug 2009, 4:40 AM
hm? from my point of view this is problem in the dwr, not ExtJs... check your dwr imports... :-)

k_new
13 Aug 2009, 12:30 AM
Thanks trnl. I agree that's the dwr's problem. The code originally is for dwr and ext js version 1(http://extjs.com/forum/showthread.php?t=5586).

I tried to fit the code to dwr and ext js version 3. The <!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 3.0//EN" "http://getahead.org/dwr/dwr30.dtd"> in dwr.xml has modified so it suit to dwr version 3. However, it still doesn't work.:((

loeppky
14 Aug 2009, 10:24 AM
hi, have you finished remaining CRUD methods ?

Just an FYI that I am back in the office now, and expect over the next week or two to work on the crud methods. Will update when I have more.

trnl
14 Aug 2009, 11:10 AM
:-) Ok... I have written some implementation, particular for 'update'...It's woks for me... I will be at office tomorrow, and I think I will finish it. I've made some changes... I will post it here...

trnl
15 Aug 2009, 6:52 AM
all right people, this is how I see DwrProxy... this is reWrite of loeppky's version... I change approach of defining dwrFunctionParams... Now, define your proxy in that way


new Ext.ux.data.DwrProxy( {
api:{
read :productService.getItemsList,
create:productService.save,
update:productService.update
},
paramNames:{
read:['filters','start','limit','sort','dir','query'],
create:['data'],
update:['data']
}
})

where in paramNames - function signature. Proxy will look for them in params variable... so we have no need to define additional loadArgs...

I'm moving to another project without extJs :(, so I have no time to finish it...

2 loeppky : thank you for proxy... I think this will help...

loeppky
24 Aug 2009, 10:45 AM
Hi guys, I still haven't had a chance to work on this. I would really like to, but I don't have a business need at the moment, as my team has be working on non-UI related code at the moment. That said, if anyone would like to have access to the GitHub repository to add in the extra CRUD functions, just let me know, and I'll grant it.

cginzel
9 Sep 2009, 8:46 AM
In using the DwrProxy to populate a combobox, I ran into a problem where IE would just forever show the "Loading..." throbber. After debugging it what I found was that the renderer callback function was undefined for IE. Here is my "fixed" doRequest with the inline logging still in place:


doRequest : function(action, records, params, reader, callback, callbackScope, options) {
Ext.log('inside doRequest');
var dataProxy = this;
Ext.log('params='+dwr.util.toDescriptiveString(params, 3));
Ext.log('this.loadArgsKey='+this.loadArgsKey);
var loadArgs = params[this.loadArgsKey] || params; // the Array or Object to build up the "dwrFunctionArgs"
Ext.log('leangth of loadArgs='+ loadArgs.length);
Ext.log('loadArgs='+dwr.util.toDescriptiveString(loadArgs, 1));
var dwrFunctionArgs = []; // the arguments that will be passed to the dwrFunction
if (loadArgs instanceof Array) {
// Note: can't do a foreach loop over arrays because Ext added the "remove" method to Array's prototype.
// This "remove" method gets added as an argument unless we explictly use numeric indexes.
for (var i = 0; i < loadArgs.length; i++) {
Ext.log('pushing index='+i+" w/ value="+loadArgs[i]);
if (loadArgs[i]!=undefined)
dwrFunctionArgs.push(loadArgs[i]);
}
} else { // loadArgs should be an Object
for (var loadArgName in loadArgs) {
Ext.log('pushing '+loadArgName+" w/ value="+loadArgs[loadArgName]);
if (loadArgs[loadArgName]!=undefined)
dwrFunctionArgs.push(loadArgs[loadArgName]);
}
}
Ext.log('setting up callback 1');
dwrFunctionArgs.push(this.createCallback(action, params, reader, callback, callbackScope, options));
Ext.log('setting up callback 2');
Ext.log(dwr.util.toDescriptiveString(dwrFunctionArgs, 3));
this.api.read.apply(Object, dwrFunctionArgs); // the scope for calling the dwrFunction doesn't matter, so we simply set it to Object.
Ext.log('callback setup');
},

The key change was to first test if loadArgs[] was undefined before pushing onto dwrFunctionArgs. For whatever undetermined reason, the length loadArgs is 2 for IE when in fact there is only one element in the array.

Here is the log on IE where you can see the length is 2 and it wants to push push the second array value which is undefined.


inside doRequest
params={
query:"",
dwrFunctionArgs:[
"ANO"
]
}
this.loadArgsKey=dwrFunctionArgs
leangth of loadArgs=2
loadArgs=["ANO"]
pushing index=0 w/ value=ANO
pushing index=1 w/ value=undefined
setting up callback 1
inside callback create function
setting up callback 2
[
"ANO",
{
callback:function,
exceptionHandler:function
}
]
callback setup

Without the check for undefined, the value of dwrFunctionArgs is


[
"ANO",
undefined,
{
callback:function,
exceptionHandler:function
}
]

and apparently the 2nd array value gets passed as the callback function?

loeppky
17 Sep 2009, 6:44 AM
Hey guys,

I have still been swamped with work, and since I don't need RESTful support for work, I haven't been able to prioritize it. Once we get done with this current sprint (next Wednesday), I'm gong to talk with management about getting a bit of time to do this.

Thanks for your patience - but also feel free to implement it yourself. I can add you to the repository so you can check in changes.

Steve

loeppky
13 Oct 2009, 8:04 AM
I'm finally getting a chance to work on this. I'm sure I'll have an update today or tomorrow on CRUD support.

cginzel
13 Oct 2009, 8:14 AM
I'm finally getting a chance to work on this. I'm sure I'll have an update today or tomorrow on CRUD support.

Looking forward to it! i'll be needing it shortly! :D

loeppky
14 Oct 2009, 7:17 PM
Quick update: I have spent some time tracking down how the newest Ext proxy code works. It's quite a mess. I'm taking notes to be able to submit back to the Ext team so they can can hopefully improve the docs. I am also having an example constructed to test/utilize the CRUD enabled proxy. I will hopefully be able to do a GitHub check-in tomorrow.

aconran
15 Oct 2009, 8:38 AM
Steve -

I'd gladly take a look at what you come up with. Please send me an email or PM when you are done.

Thx,

loeppky
16 Oct 2009, 5:28 AM
Hello,

I am pleased to report that an initial CRUD implementation of DwrProxy has been pushed to github, and it includes a full working example. Over the next couple of days, I will be:

Documenting it further.
Providing a writeup with the Ext team about some confusing/inconsistent elements in their proxy code/documentation.


This CRUD implementation is not backwards compatible with the read-only version. In my documenting, I will explain how one upgrades. Until I give the "all clear", I won't be providing any support for the crud-enabled proxy. I have committed this change so that those who are needing this functionality can get started, and give me feedback on the approach.

Expect to hear more soon!
Steve

loeppky
16 Oct 2009, 5:33 AM
Hi Aaron,

I have committed my initial crud-enabled version here: http://github.com/BigLep/ExtJsWithDwr/blob/v3/src/data/DwrProxy.js. If you get a chance, do you want to take a look?

I have also made notes about areas of unclarity within the Ext-provided store/reader/writer/proxy code that I'll be formalizing over the next couple of days. Weeding through the Ext provided proxy-code was a bit of an undertaking, and with some documentation code/improvements, I think this could be made easier for others in the future.

Steve


Steve -

I'd gladly take a look at what you come up with. Please send me an email or PM when you are done.

Thx,

loeppky
16 Oct 2009, 10:15 AM
Hello,

The DWR team is going to be able to host my examples that show Ext and DWR integration. Here is a temporary URL that demonstrated the CRUD example: http://slurm.dojotoolkit.org/extJsWithDwrExamples/dwrProxy/crud/

Again, the this is for demonstration purposes. The CRUD-enabled DwrProxy will be ready for prime time in a few days once I have spent more time documenting it.

Steve

davemeurer
11 Nov 2009, 6:20 AM
Hello loeppky,

First, thank you for an excellent DWRProxy implementation, as well as the CRUD operations!! Very helpful for an EXTJS newbie like myself.

Second, I am using it with a Spring/DWR approach with an EditorGridPanel, and I noticed the cell updates would not commit to the DB if I attached a record.commit() as a listener to the EditorGridPanel. If I clicked on another cell in the same row and edited, the first cell edit would then commit to the database.

I resolved this by switching the parameters in the dwrproxy.js update extension. It appears the update command was using the original data before the edit... so,

instead of:

return [oldRecordDataArray, recordDataArray];
I am using

return [recordDataArray, oldRecordDataArray];
...and that seems to work.

Are there any impacts I need to be aware of with making this change? Is there a better approach that I am missing?

Kind regards,
Dave

loeppky
11 Nov 2009, 9:22 AM
davemeurer:

The line you change (278 on http://github.com/BigLep/ExtJsWithDwr/blob/v3/src/data/DwrProxy.js right?) has to do with how data is sent to the DWR backend. Is your Java backend expecting recordDataArray and then oldRecordDataArray? If so, then that explains why that change works for you.

That said, instead of modify DwrProxy directly, you should pass in a apiActionToHandlerMap that defines a value for update when constructing your Ext.ux.data.DwrProxy.



new Ext.ux.data.DwrProxy({
apiActionToHandlerMap : {
update : {
dwrFunction : yourDwrFunction,
getDwrArgsFunction: function(request, recordDataArray, oldRecordDataArray) {
return [recordDataArray, oldRecordDataArray];
},
getDwrArgsScope : whateverScopeYouWant
}
}
});


That said, I'm not sure why you are calling record.commit() manually. Ideally a Ext.data.Store should be managing that for you (see http://www.extjs.com/deploy/dev/docs/?class=Ext.data.Record).

Steve

davemeurer
11 Nov 2009, 12:21 PM
Thank you Steve!

That is absolutely correct, line 278 - and now that you mention it, the lightbulb went off! Yes, my Spring service is expecting only the updated value, and the sample code to change apiActionToHandlerMap helped a ton.

You mentioned another correct point as well - I removed the manual commit and all worked as documented. I did read that fact while creating this app, but put the manual commit in there while troubleshooting other issues I was facing... all part of the newbie learning process :">

Thanks for the prompt help! I'm planning to blog about a Skyway Builder + Spring + DWR + DwrProxy/Ext JS CRUD app this week using the EditorGridPanel, and I will be sure to mention and link to your DwrProxy links!!

Kind regards,
Dave

loeppky
12 Nov 2009, 8:26 AM
davemeurer: you're most welcome. Let me know when you've written your blog entry; I'd like to read it.

davemeurer
12 Nov 2009, 12:00 PM
Absolutely! It would be great to get your comments on the blog and especially if I can do things easier with DWR and EXT JS.

I just finished it, here is the link: Skyway + Spring + DWR + EXT JS + CRUD: http://www.skywayperspectives.org/blog/?p=1235

hat27533
13 Nov 2009, 8:57 AM
loeppky great work on this.

I am trying to use the DwrProxy with extjs 3.0.3 with a combo with an XTemplate. I cant figure out how to populate my Java method paramater:-

This is the java method snippet

public String emailSearch(String searchString){
......
}

this is the combo stuff :-

var ds = new Ext.data.Store({
proxy: new Ext.ux.data.DwrProxy({
apiActionToHandlerMap : {
read : {
dwrFunction : dwrRemote.emailSearch
}
}
}),
reader: new Ext.data.JsonReader({
root: 'ADDRESSES',
totalProperty: 'totalCount',
id: 'EMPLOYEE'
}, [
{
name: 'employee',
mapping: 'EMPLOYEE'
},

{
name: 'FULL_NAME',
mapping: 'FULL_NAME'
},

{
name: 'EMAIL_ADDRESS',
mapping: 'EMAIL_ADDRESS'
}
])
});


var emailToCombo = new Ext.form.ComboBox({
fieldLabel:'To',
store: ds,
displayField:'EMAIL_ADDRESS',
typeAhead: false,
loadingText: 'Searching...',
width: 350,
pageSize:10,
hideTrigger:true,
tpl: new Ext.XTemplate(
'<tpl for="."><div class="search-item">',
'<h3><span>{EMAIL_ADDRESS}<br />{FULL_NAME}</span>{EMAIL_ADDRESS}</h3>',
'{EMAIL_ADDRESS}',
'</div></tpl>'
)
});


The java method is returning the correct JSON when I test it in the DWR debug page entering the search string manualy.

Any pointers ?

cginzel
13 Nov 2009, 10:40 AM
Since you are using DWR, don't build a JSON string!!! Define your java class and return that. DWR handles the marshalling of your java class to JSON and back again. That's the whole purpose of using the DWRProxy with DWR. If you are going to build the JSON strings yourself, then don't use DWR! Did you look at the example for DWRProxy?

longsuh
13 Nov 2009, 6:14 PM
I'm looking for someone to design a new website since I feel like my wordpress one is kind of dull. Maybe make it a forum based website or something, but jazzed up a bit. Our current forums isn't very spruced up and seems pretty plain.

UrfinDjusse
2 Mar 2010, 3:33 PM
Hi.
My DWR method return xml string


//#DWR-INSERT
//#DWR-REPLY
dwr.engine.remote.handleCallback("1","0","<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><dataset><row><OSTI>0</OSTI><OSTV>0</OSTV><VKD>0</VKD><ID>5</ID></row><row><OSTI>0</OSTI><OSTV>0</OSTV><VKD>498</VKD><ID>3</ID></row><row><OSTI>0</OSTI><OSTV>0</OSTV><VKD>810</VKD><ID>4</ID></row><row><OSTI>0</OSTI><OSTV>0</OSTV><VKD>840</VKD><ID>1</ID></row><row><OSTI>0</OSTI><OSTV>0</OSTV><VKD>978</VKD><ID>2</ID></row><total>5</total></dataset>");

my script.js


var RecordDef = new Ext.data.Record.create([
{name: 'OSTI'},
{name: 'OSTV'},
{name: 'VKD'},
{name: 'ID'} ]);

var myReader = new Ext.data.XmlReader({
idProperty: 'id',
record: 'row',
totalProperty : 'total'
}, RecordDef);

var store = new Ext.data.Store({
proxy: new Ext.ux.data.DwrProxy({
apiActionToHandlerMap : {
read : {
dwrFunction : ServiceHub.accountRests
}
}
}),
reader: reader
});

store.on('load', function(){
alert( store.getTotalCount())
});
store.load();
}

but to records loaded to Store , DwrProxy working with XmlReader or only with JsonReader ?
Thanx.

paoloyx
29 Mar 2010, 1:21 AM
@hat27533 (http://www.extjs.com/forum/member.php?u=15979)

Hi, i'm in your same situation....i'm using a spring/dwr exposed manager with a method like this:



public interface CustomerManager {

List<Customer> searchCustomer(String name, String surname);

}I've setup a SimpleStore like the one here:


var customerRecord = new Ext.data.Record.create([{
name : 'id',
type : 'string'
}, {
name : 'surname',
type : 'string'
}, {
name : 'name',
type : 'string'
}, {
name : 'birthDate',
type : 'date'
}]);

var customerStore = new Ext.data.SimpleStore({
proxy : new Ext.ux.data.DwrProxy({
apiActionToHandlerMap : {
read : {
dwrFunction : CustomerManager.searchCustomer
// Should i put here my parameters??
}
}
}),
reader : new Ext.data.JsonReader({
fields : customerRecord
})
});
however i can't figure how can i pass the parameters (name and surname) to the CustomerManager.searchCustomer method.

Is there anyone here that can point me in the right direction? :)

Thank you very much!

Paolo

paoloyx
29 Mar 2010, 1:29 AM
@hat27533: Have you managed to solve your problem about the parameter passing? I'm in your same situation...

I've got a Spring/DWR exposed manager like this:



public interface CustomerManager {

List<Customer> searchCustomer(String name, String surname);

}
The CustomerManager.searchCustomer method works well in the test page tha DWR setups automatically.
I've tried to setup a DwrProxy based store like this one:



var customerRecord = new Ext.data.Record.create([{
name : 'id',
type : 'string'
}, {
name : 'surname',
type : 'string'
}, {
name : 'name',
type : 'string'
}, {
name : 'birthDate',
type : 'date'
}]);

var customerStore = new Ext.data.SimpleStore({
proxy : new Ext.ux.data.DwrProxy({
apiActionToHandlerMap : {
read : {
dwrFunction : CustomerManager.searchCustomer
// Should i put here my parameters??
}
}
}),
reader : new Ext.data.JsonReader({
fields : customerRecord
})
});
However i can't figure how to pass parameters (name and surname) to the CustomerManager.searchCustomer method.
Is there anyone here that can point me in the right direction? :)

Thank you all...

Paolo

carol.ext
29 Mar 2010, 6:00 PM
Post 23 (http://www.extjs.com/forum/showthread.php?p=407672#post407672) of this thread defines "getDwrArgsFunction" to pass the parameters, also it is used in the "basic read" example in the download. Did you try using that?



proxy: new Ext.ux.data.DwrProxy({
apiActionToHandlerMap : {
read : {
dwrFunction : BasicReadExampleInterface.getGridData,
getDwrArgsFunction : function(trans) {
return [
formPanel.getForm().findField('baseString').getValue(),
formPanel.getForm().findField('numberOfRows').getValue()
];
}
}
}
}),

paoloyx
30 Mar 2010, 5:22 AM
@carol.ext: you're absolutely right.....it was my dullness, probably. I've downloaded the src with examples from github and i've been able to call the method with parameter passing.

I'll continue diving into the fabulous extjs sea :)

Thanks a lot,

Paolo

rapadder
5 May 2010, 3:51 AM
I get an error when I am trying to run crud example in ExtJsWithDwr (http://github.com/BigLep/ExtJsWithDwr/tree/v3) crud example:
SEVERE: Class not found: 'CrudExampleInterface'

The same error with the BasicReadExample.java:
SEVERE: Class not found: 'BasicReadExampleInterface'

I see that index.html needs the following files:

<!-- DWR Dependencies -->
<script type="text/javascript" src="../../dwr/interface/CrudExampleInterface.js"></script>
<script type="text/javascript" src="../../dwr/engine.js"></script>


Where can I download CrudExampleInterface.js and BasicReadExampleInterface.js? I can't find them in the gitHub...

sh3riff99
9 May 2010, 9:04 PM
BasicReadExampleInterface and CrudExampleInterface are just a proxy name that will be used within DwrProxy.

Open BasicReadExample.java and look at the line right before the constructor -- that's where the proxy name is defined.

rapadder
10 May 2010, 1:32 AM
I understood the use of annotations. But why do I get this error:
...
INFO: Server startup in 251 ms
10 May 2010 12:25:33 μμ org.directwebremoting.impl.StartupUtil logStartup
INFO: Starting: DwrServlet v3.0.0.116.rc1 on Apache Tomcat/6.0.26 / JDK 1.5.0_09 from Sun Microsystems Inc. at /ExtJsWithDwr
10 May 2010 12:25:33 μμ org.directwebremoting.impl.DefaultCreatorManager getCreator
SEVERE: Class not found: 'BasicReadExampleInterface'
10 May 2010 12:25:33 μμ org.directwebremoting.impl.DefaultCreatorManager getCreator
WARNING: Names of known classes are: CrudExample __System __Data
10 May 2010 12:25:33 μμ org.directwebremoting.servlet.ExceptionHandler handle
WARNING: Error: java.lang.SecurityException: Class not found

BasicReadExample is properly defined in web.xml. I have downloaded the source directly from github and created a relevant Eclipse project (http://dl.dropbox.com/u/388688/ExtJsWithDwr.rar).

sh3riff99
10 May 2010, 4:23 PM
What I did to make this sample works was simply git, build and deploy - used exactly what's given.

I see you use DWR 3.0 rc1 as opposed to DWR 2.0.5 used by the example. Try using the one given in the example and see how it goes.

rapadder
10 May 2010, 11:19 PM
You are correct! I replaced the DWR 3.0 rc1, build the project and voila! Thank you very much for your help. You can find the relevant Eclipse project here (http://dl.dropbox.com/u/388688/ExtJsWithDwr.rar).

sh3riff99
18 May 2010, 5:29 PM
Does anyone have a working example of configuration for DwrProxy and Spring using DWR annotation?

I hit an issue when I add the following config in web.xml:

<servlet>
<servlet-name>dwr</servlet-name>
<servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>classes</param-name>
<param-value>
com.xx.Class1,
com.xx.JsonReaderResponse
</param-value>
</init-param>
</servlet>

I have dataSource configured and tested in applicationContext.xml, use Hibernate as ORM provider, add @RemoteProxy, @RemoteMethod to the Dao class that queries from database. Method invocation from ExtJs keeps failing with NullPointerException. Then I debug getHibernateTemplate() and it is null.

When I take out the above servlet configration from web.xml (not using DwrServlet) and use the old DWR configuration via <dwr:remote> everything's fine. Looks like if I add @RemoteProxy the Hibernate related properties didn't get assigned properly.

I can't figure out what steps I'm missing in the configuration.

Any help is much appreciated.

sh3riff99
18 May 2010, 5:59 PM
Nevermind, it's fixed.

Had to annotate with:

@RemoteProxy(
creator = SpringCreator.class,
creatorParams = @Param(name="beanName", value="yourDao")
name = "JavascriptInterface"
)

sh3riff99
18 May 2010, 6:19 PM
Strange..

Looks like remote method doesn't get fired up. Here's the log:

12:05:21,812 DEBUG DebuggingPrintWriter:43 - out(17): //#DWR-INSERT
12:05:21,812 DEBUG DebuggingPrintWriter:43 - out(17): //#DWR-REPLY
12:05:21,812 DEBUG DebuggingPrintWriter:43 - out(17): var s0={};var s1={};var s2
={};var s3={};var s4={};var s5={};var s6={};var s7={};var s8={};var s9={};var s1
0={};var s11={};var s12={};var s13={};var s14={};var s15={};















dwr.engine._remoteHandleCallback('0','0',[s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,
s12,s13,s14,s15]);

There are 16 records returned by Hibernate but they're all empty when they reach DWR.

All I have in the remote method is:

@RemoteMethod
public JsonReaderResponse<Model> getAll() {
if (logger.isDebugEnabled()) logger.debug("queryDao = " + queryDao);
List<Model> l = queryDao.getAll();
return new JsonReaderResponse<Model>(l);
}

Debug logging enabled and I don't see that line output in the tomcat log and that tells me that this method doesn't get invoked at all.

Anybody know what could be the issue here?

Thanks for your help

sh3riff99
18 May 2010, 6:43 PM
Fixed by adding: @DataTransferObject(converter = H3BeanConverter.class) in the model class

sh3riff99
18 May 2010, 7:33 PM
I'd like to share some tips in regards to using DwrProxy with DWR Annotation and Spring and Hibernate:

1. JsonReaderResponse is not needed because when you annotate a model class' converter as H3BeanConverter, the return values are automatically converted to JSON format by DWR. I haven't debugged in detail but I think when you define creator name as SpringCreator in @RemoteProxy, it also plays in part of the auto value conversion to JSON format.

2. Since JsonReaderResponse is not in play anymore hence "root" property in Ext.data.JsonReader must be set to ''.

3. The only DWR related configs you need to have in applicationContext.xml are:

<dwr:controller id="dwrController" debug="true" />

<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/dwr/**/*.*">dwrController</prop>
<prop key="/dwr/**/*">dwrController</prop>
<prop key="/dwr/*">dwrController</prop>
<prop key="/dwr">dwrController</prop>
</props>
</property>
<property name="alwaysUseFullPath" value="true" />
</bean>

<dwr:configuration />

The DWR config in web.xml is the similar to the one given in the DwrProxy example.

These three things that took me 1 day to figure out. Glad it all sorted out now.

Happy coding :)

atulmore
19 May 2010, 1:38 AM
Thanks !!!:)







I'd like to share some tips in regards to using DwrProxy with DWR Annotation and Spring and Hibernate:

1. JsonReaderResponse is not needed because when you annotate a model class' converter as H3BeanConverter, the return values are automatically converted to JSON format by DWR. I haven't debugged in detail but I think when you define creator name as SpringCreator in @RemoteProxy, it also plays in part of the auto value conversion to JSON format.

2. Since JsonReaderResponse is not in play anymore hence "root" property in Ext.data.JsonReader must be set to ''.

3. The only DWR related configs you need to have in applicationContext.xml are:

<dwr:controller id="dwrController" debug="true" />

<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/dwr/**/*.*">dwrController</prop>
<prop key="/dwr/**/*">dwrController</prop>
<prop key="/dwr/*">dwrController</prop>
<prop key="/dwr">dwrController</prop>
</props>
</property>
<property name="alwaysUseFullPath" value="true" />
</bean>

<dwr:configuration />

The DWR config in web.xml is the similar to the one given in the DwrProxy example.

These three things that took me 1 day to figure out. Glad it all sorted out now.

Happy coding :)

softwareengineer
31 May 2010, 8:06 PM
Thanks !!!:)
I have same problem here.
My DWR java method returns JsonReaderResponse<CustomerOrder> means list of customerorder.In java this method getting execute perfectly but i am not getting data on grid.
Can any one please guide me.
Below is my JsonReaderResponse class.
package com.github.extjswithdwr;

import java.util.List;

import org.directwebremoting.annotations.DataTransferObject;
import org.directwebremoting.annotations.RemoteProperty;
import org.directwebremoting.convert.ObjectConverter;

/**
* Creates a response that can be consumed by an Ext.data.JsonReader.
* The client-side Ext.data.JsonReader must have the "root" property set to "objectsToConvertToRecords".
* Note: Ext documentation often uses "rows" for this property, but "objectsToConvertToRecords" is more clear.
* Example Ext.data.JsonReader configuration:
* {
* root : 'objectsToConvertToRecords'
* }
* If the parameterized type has two properties "field1" and "field2", then when an instance of this class is read by the client,
* it will look like:
* {
* objectsToConvertToRecords : [
* {
* field1 : 'value',
* field2 : 'value',
* }, {
* field1 : 'value',
* field2 : 'value',
* }
* ],
* success : true
* }
* @param <T> Type of Objects that will be converted to Ext.data.Records by the client-side Ext.data.DataReader.
*/
@DataTransferObject(converter = ObjectConverter.class)
public class JsonReaderResponse<T> {

@RemoteProperty
public List<T> objectsToConvertToRecords;

/**
* @see Ext.data.JsonReader.successProperty
*/
@RemoteProperty
public boolean success;

/**
* Creates a {@link #success}ful JsonReaderResponse with the provided {@link #objectsToConvertToRecords}.
* @param objectsToConvertToRecords
*/
public JsonReaderResponse(List<T> objectsToConvertToRecords) {
this.objectsToConvertToRecords = objectsToConvertToRecords;
success = true;
}

/**
* Creates an un{@link #success}ful JsonReaderResponse with null {@link #objectsToConvertToRecords}.
* This signals the case where the client established a connection with the server,
* but the server couldn't fulfill it (e.g., user doesn't have proper user credentials).
* @param objectsToConvertToRecords
*/
public JsonReaderResponse() {
this.objectsToConvertToRecords = null;
success = false;
}
}

Tod
27 Oct 2010, 10:56 AM
I have DwrProxy working with load and update... very nice work! However, if something goes wrong server side, I'm not understanding how I can detect this and at least let the user know, on the client. For example, say that when the server processes the update for the store, it encounters an error. I see that Ext.Ajax.request has a "success" and "failure" callback... is there any sort of callback for Dwr? Does the value I pass back from my update function matter? Or is this handled via exceptions? Any examples?

Thanks,
-Tod

Tod
9 Nov 2010, 5:47 AM
So is nobody using DwrProxy? So far everything is good but I really need the error handling. I was hoping that the store would fire an exception event that I could listen to in case the server threw an exception instead of simply returning data in the Dwr method but I am not seeing it. If anybody has any insite, I would be most grateful for your posting. Thanks!

seek
5 Apr 2011, 6:33 AM
Hi all,
there is a way to intercept/override the onRead function?
I must read some JSON data from a jdbc query (just a custom query in my project).
Java:


...
ps = conn.prepareStatement(qryComb.toString(), ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
if(ps.execute()){
rs = ps.getResultSet();
JSON.append("{items:[");
while(rs.next()){
JSON.append("{");
for (Integer i = 0; i <= ColumnNumbers-1; i++) {
log.debug("A"+i.toString());
addString(JSON, "A"+i.toString(), rs);
JSON.append(",");
};
addString(JSON, "sc", rs);
JSON.append(",");
addString(JSON, "pia", rs);
JSON.append("}");
if(!rs.isLast()){
JSON.append(",");
};
totalRows+=1;
};
};
JSON.append("]");
JSON.append(",totalCount:"+totalRows+"}");
...

Javascript:


....
onRead : function(request, response) {
var readDataBlock;
try {
// Call readRecords() instead of read because read() will attempt to decode JSON to create an Object,
// but as this point DWR has already created an Object.
readDataBlock = request.reader.readRecords(response);<--HERE I NEED TO Ext.decode() datas
} catch(e) {
return this.handleResponseException(request, response, e);
}
if (readDataBlock.success === false) {
this.fireEvent("exception", this, 'remote', request.action, request.options, response, null);
} else {
this.fireEvent("load", this, request, request.options);
}
request.callback.call(request.scope, readDataBlock, request.options, readDataBlock.success);
},....

Maybe I must solve my problem in Java app?

Thanks
Seek

smokeman
15 Jul 2011, 10:07 AM
sorry for the non extjswithdwr post(I'm looking at using it BTW),
but I noticed in the code snippet above the JSON.append.
I was looking for a way to use json_encode in java, as I do with php, and found gson.
All I do to convert an object to json now is
import com.google.gson.*;
String json = new Gson().toJson(office);

smokeman
15 Jul 2011, 10:09 AM
any extjs 4.x support planned?

loeppky
18 Jul 2011, 7:38 AM
For working with JSON in Java, I highly suggest Jackson: http://jackson.codehaus.org/

Concerning Ext 4 support, I will do it as soon as it's needed with my work. We're still using Ext 3 at the moment, and have a lot of backend projects we're working on, thus Ext 4 support hasn't been the top priority. Feel free to fork the project in GitHub though.

farkare
19 Jul 2011, 3:01 AM
It seems ExtJsWithDwr project only supports Ext3, there are couple of things which are removed from Ext4 such as Ext.data.Api, DataProxy etc.

Is there any other solution to get it done with Ext4?

Thanks in advance.

arpan
21 Aug 2011, 10:46 AM
I have made a Ext JS+DWR+Spring dynamic web aplication in eclipse.Could anyone tell me where I can put that in sencha website please?

Regards

arpan
22 Aug 2011, 10:29 PM
Your DWR3 proxy is working fine with public property in the Employee class.But in case of private property can I access those from javascript using that DWR proxy


Regards

guessit
30 Sep 2011, 10:18 AM
Loeppky

I am using ext.ux.data.dwrProxy for dwrcalls and I am not able to handle the exception that we get when dwr calls are performed. The exact problem that I have is when a dwr call is made and the tomcat server is down I am receiving the error popup service temporary unavailable which I want to change it to more user friendly. But I am not able to catch the exception. Is there any listener that can be configured for exceptions. I am using the latest version of dataProxy and dwr3.0 rc1. Please let me know how to handle this as this is crititcal.