0 Replies Latest reply on Apr 26, 2007 10:23 AM by rlhr

    Possible new heature in Remoting?

      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