View Poll Results: If you read it, did you find DirectJNgine User's Guide adequate?
- Voters
- 54. You may not vote on this poll
-
Yes
40 74.07% -
No
14 25.93%
-
18 Jun 2010 5:54 AM #321
Hey,
I can't say enough how valuable this package is for my app!! Thank you!!
Quick question. I have to access some local variables in my method callbacks. Is there a way to pass them in or set the scope so that multiple callbacks will get the values passed to them? I couldn't see how this can be done.
I use a loop and need to pass the loop value at the time of each invocation (so it stays fixed), so I can't just reference the variable directly.
thanks!!
Darren
-
20 Jun 2010 1:00 AM #322
DirectJNgine 1.3 final is out
DirectJNgine 1.3 final is out
Today I have released DJN 1.3 final, aimed at supporting Google's AppEngine.
You can download it from http://code.google.com/p/directjngine/
For details, check this entry in my blog.
Regards,Pedro Agulló, Barcelona (Spain)
Agile team building, consulting, training & development
DirectJNgine: http://code.google.com/p/directjngine - Log4js-ext: http://www.softwarementors.com/projects/p/log4js-ext/
-
20 Jun 2010 4:03 AM #323
Thanks, I never get tired of hearing such things...

Hmmm. I'm not sure I understand what you really mean, so take the following answer/reflection with a bit of salt.Quick question. I have to access some local variables in my method callbacks. Is there a way to pass them in or set the scope so that multiple callbacks will get the values passed to them? I couldn't see how this can be done.
I use a loop and need to pass the loop value at the time of each invocation (so it stays fixed), so I can't just reference the variable directly.
This seems a lot like the kind of thing you should coordinate on the server side, passing the information you want to share among calls to a stateful object *before* you invoke the methods that need to acccess the shared information.
Then, subsequent calls to methods, which should belong to that object, will have access to the shared data.
Or you could use the other mechanisms provided by DJN to access session/application data and store your temporary information there.
You might want to use a list to store the information per loop (list index=current loop index), so that the invoked methods receive the index and can access the data corresponding to the loop they are handling -needed because of asynchronicity...
But, of course, you need to make sure the methods are not invoked before the appropriate per-loop data is initialized. Not terribly difficult, though.
But, frankly, I'm not sure I see the whole context, so I might be misfiring. Could you provide us with more details?
Regards,Pedro Agulló, Barcelona (Spain)
Agile team building, consulting, training & development
DirectJNgine: http://code.google.com/p/directjngine - Log4js-ext: http://www.softwarementors.com/projects/p/log4js-ext/
-
1 Jul 2010 12:08 AM #324
can i user org.json.JSONObject or json-lib or flex-json object to return json object
can i user org.json.JSONObject or json-lib or flex-json object to return json object
can i user org.json.JSONObject or json-lib or flex-json object to return json object?
I want write a directMethod that return a org.json.JSONObject but ,google-gson can not recogniza my JSONObject().

-
1 Jul 2010 12:33 AM #325
this framework (the gson framework) transforms the Java Type automatically to a json object.
For example Hashmap will be a javascript object with key-value pairs.
a String array in Java will also be returned as a json String array and so on. There's no need to build a json object and then return it. The framework does the work..
Example:
]and at the JavaScript side, there will be this:PHP Code:Java:
@DirectMethod
public HashMap<String,String> getAnyObject(){
HashMap<String,String> anyObject = new HashMap<String,String>();
anyObject.put("key","value");
return anyObject;
}
@DirectMethod
public HashMap<String,String[]> getAnotherObject(){
HashMap<String,String[]> anotherObject = new HashMap<String,String[]>();
anotherObject.put("key",new String[]{"value 1","value 2"});
return anotherObject;
}
@DirectMethod
public HashMap<String,HashMap<String,String[]>> getLastObject(){
HashMap<String,HashMap<String,String[]>> lastObject = new HashMap<String,HashMap<String,String[]>>();
HashMap<String,String[]> tmpMap = new HashMap<String,String[]>();
tmpMap.put("key",new String[]{"value1","value2"});
lastObject.put("key",tmpMap);
return lastObject;
}
if you now use something like this:PHP Code:result of Method: getAnyObject()
{"tid":6,"action":"DemoClass","method":"getAnyObject","result":{"key":"value"},"type":"rpc"}
result of Method: getAnotherObject()
{"tid":7,"action":"DemoClass","method":"getAnotherObject","result":{"key":["value 1","value 2"]},"type":"rpc"}result of Method: getLastObject()
{"tid":8,"action":"DemoClass","method":"getLastObject","result":{"key":{"key":["value1","value2"]}},"type":"rpc"}
you'll have a pretty fine javascript objectPHP Code:DemoClass.getLastObject(function(result,e){
if(e.status){
console.log(result);
}
})

-
1 Jul 2010 12:37 AM #326
-
1 Jul 2010 12:54 AM #327
to #325:
your reslution is a good way !
I post this becase a old project use many org.json.JSONObject as return type in action layer,i need a quck way to refactor classes.
and I think this project need more work to have a well designed structure
-
1 Jul 2010 1:21 AM #328
-
3 Jul 2010 1:13 PM #329
Hey there.
So let's say I want to kick off a method call on the client. I pass a few parameters and want to update some GUI objects when the callback is received. Since the method call is asynchronous, it goes out of scope from where it was called. If there was a way to add a scope or context with the method call, then my callbacks have direct access to javascript variables that the callback might need without having to store and fetch it another way.
Does this make sense? The server would not be involved in that data.
-
26 Jul 2010 4:57 AM #330
Hi again,
When submitting forms, I am only getting the Name field, not the Value field for a form element (combo).
Is this something going on in directjngine? I have all the form parameters set for each field and the form has the correct values in the fields, but when received on the server, they are the "name" values of the field, not the "value" value.
Any help appreciated.


Reply With Quote