PDA

View Full Version : djn Multiple Parameters



GregT
11 Oct 2009, 2:49 PM
This works:

StlTest.testThis('test',function(result,e){
var t = e.getTransaction();
alert(Ext.encode(result) + "," + e.status + "," + e.message);
});

But this does NOT work:

var par = new Array();
par[0] = 'test';
par[1] = 'text';

StlTest.testThat(par,function(result,e){
var t = e.getTransaction();
alert(Ext.encode(result) + "," + e.status + "," + e.message);
});

Neither does this:

StlTest.testThat('foo','bar',function(result,e){
var t = e.getTransaction();
alert(Ext.encode(result) + "," + e.status + "," + e.message);
});

The Api.js looks OK:

Ext.app.REMOTING_API = {
url: Ext.app.PROVIDER_BASE_URL,
type: 'remoting',
actions: {
StlTest: [
{
name: 'loadStore'/*() => java.util.List */,
len: 0,
formHandler: false
},
{
name: 'testThat'/*(String, String) => String */,
len: 2,
formHandler: false
},
{
name: 'testThis'/*(String) => String */,
len: 1,
formHandler: false
}
]
}
}

Any advice appreciated, thanks!

pagullo
12 Oct 2009, 11:54 PM
Greg:

The second case should not work: the Javascript code passes an array, and the Java code receives two strings. If you want to pass an array, pass an array to the Java method too.

To check the third case, I need more information:

- The Java code.
- The JSON sent to the server, and that returned by it (if applicable). Configure log4j to log DJN-related data (check the User's Guide).
- Error information, both for Javascript and Java -if applicable.
- The web.xml.

You can check ServerMethodParametersReceptionTest.java and ServerMethodReturnTest.java for working examples of passing arrays, etc.

BTW: can you please move this discussion to the main DJN thread? I prefer all DJN-related things to be available in just one place, if at all possible.

GregT
13 Oct 2009, 6:38 AM
Hi Pedro,

Thanks for the reply. I eventually figured this out, I was referencing a stale Api.js, I fixed this and now it works intuitively (eg. the first way).

I am not sure where the main DJN thread of which you speak is?

I have a small suggestion for your User Guide. I spent yesterday afternoon figuring out how to handle the case of a single DJN call passing back multiple Stores. This was not terribly hard thanks to your manual plus the excellent Ext API documentation (and some lucky guesses on my part), but it would be helpful if your guide had an example.

This must be a common case and it seems to require a totally different approach compared to the example in your guide. I am not certain whether I am doing it the "right way", though it definitely works.

Cheers,
Greg

pagullo
13 Oct 2009, 10:42 AM
Hi:

I'm wonder what happened to your api file. It is rewritten by DJN as needed so that the Javascript code never gets out of sync with the Java code, unless there is some fatal error -which should be reported.

The DJN "main thread" is the one titled Ext Direct Java based implementation (http://www.extjs.com/forum/showthread.php?t=73027) in this forum.

It is common practice that questions related to a given implementation (.net, PHP, Java, etc.) are posted in their own thread, with "general" question being posted in new threads. That way everything related to DJN is kept together.

Regards,