[jboss-user] [JBoss Seam] - Possible new heature in Remoting?

rlhr do-not-reply at jboss.com
Thu Apr 26 10:23:21 EDT 2007


Hello,

I'd like to be able to associate a context to the callback method.
At this point, we perform a remote call as:


  | Seam.Component.getInstance("myComponent").myMethod(param1, myCallback);
  | 

I have the need for something like:

  | Seam.Component.getInstance("myComponent").myMethod(param1, myCallback, myCallbackContext);
  | 

Where myCallbackContext  is an object that has a method named myCallback (which is a string is that case).
myCallback would be call this way:  myCallbackContext[myCallback]

I'm not sure I'm very clear here... So let me know :)

So looking at the Remote.js, I think this should be a faily simple change.

First, Seam.Remoting.createCall should become:


  | Seam.Remoting.createCall = function(component, methodName, params, callback, callbackContext) {
  | ...
  |   return {data: data, id: callId, callback: callback, callbackContext: callbackContext};
  | }
  | 

Then Seam.Remoting.processResult should become:


  | Seam.Remoting.processResult = function(result, context){
  | ...
  |     if(call.callbackContext){
  |         call.callbackContext[call.callback](value, context);
  |     } else {
  |         call.callback(value, context);
  |     }
  | }
  | 

There might be some other changes in some other places. I didn't look carefully at all the code, but I think that should be it.

Making that change would allows more "object oriented" javascript code to make call within there context.

Let me know if it makes sense to you. That would make my code much cleaner.

Regards,

Richard

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4041002#4041002

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4041002



More information about the jboss-user mailing list