4 Replies Latest reply on Jan 15, 2008 3:14 AM by Milli Coelho

    Seam remoting or DWR

    Fang zx Newbie

      I used DWR before, and switched to JBoss Seam recently.

      Can I still use DWR instead of Seam remoting?
      Can Seam remoting make synchronous call like DWR?

        • 1. Re: Seam remoting or DWR
          Fang zx Newbie

          After two days hard work, I decided to modify remote.js in
          jboss-seam-remoting.jar to support synchronous call.

          old code:

          asyncReq.open("POST", Seam.Remoting.resourcePath + path, true);


          new code :

          asyncReq.open("POST", Seam.Remoting.resourcePath + path, Seam.Remoting.async);


          I create an utility method to remoting call that can used by DWR and
          JBoss Seam Remoting:

          function rmtCall(method, callback, params, isAsync) {
           var s = method.split('.');
           var callParams = [];
           if (params) {
           for (i = 0;i < params.length; i++) {
           callParams.push(params);
           }
           }
           if (Seam.serverSide) {
           callParams.push(callback);
           var obj = Seam.Component.newInstance(s[0]);
           Seam.Remoting.async = isAsync;
           eval('obj.' + s[1] + '.apply(obj, callParams)');
           } else {
           callParams.push( {
           callback : callback,
           async : isAsync
           });
           eval(method + '.apply(' + s[0] + ', callParams)');
           }
           }
          


          Any comments are appreciated.


          • 2. Re: Seam remoting or DWR
            Shane Bryzak Master

            I'm not really a fan of synchronous ajax requests, however I think the approach that you've taken is fine.

            • 3. Re: Seam remoting or DWR
              Fang zx Newbie

              There are times and situations where asynchronous just will not do.

              I agree that it is ideal to use async requests as much as possible,
              even if it requires refactoring much of your other code to make it work that way.
              However, there is value in having the option to make a synchronous call if one should wish,
              and there are situations where it may be desired.

              • 4. Re: Seam remoting or DWR
                Milli Coelho Newbie

                I'm using flex in one of the pages and need to find out if a user is logged in and get his id. I would need a synchronous WebRemote call in this case so that flex can call a javascript function and get the result.

                Fangzx, I couldn't make your utility method to work but I was able to override Seam.Remoting.sendAjaxRequest and use a modified Seam.Remoting.processResponse and Seam.Remoting.processResult methods in the application.

                Now I could do both synchronous and asynchronous calls in the application without touching seam-remoting.jar.