-
1. Re: Synchronous @WebRemote call
frer Jun 16, 2008 4:34 AM (in response to frer)I have found my answer with this thread:
http://www.seamframework.org/Community/EJBInjectionInAServlet
Here is the code snippet that I use:
remoteCall: function(method, params, callback, isAsync) { var async = (isAsync != null)? isAsync : true; var s = method.split('.'); var callParams = [params, callback]; var obj = Seam.Component.newInstance(s[0]); Seam.Remoting.async = async; eval('obj.' + s[1] + '.apply(obj, callParams)'); }
Unfortunately I did need to modify remote.js in order to get this working by adding the parameter for synchronicity:
Line 602 (added)
//FRER: Variable that holds state of the request Seam.Remoting.async = null;
Line 634-640 (added)
//FRER: Use async to specify if it is a synchronous or asynchronous request var async = (Seam.Remoting.async != null)? Seam.Remoting.async : true; asyncReq.open("POST", Seam.Remoting.resourcePath + path, async); //FRER: Once it is done reset it to null Seam.Remoting.async = null;
Obviously it would be great if a parameter could be added to the method calls with Seam Remoting directly...
Francois
-
2. Re: Synchronous @WebRemote call
frer Dec 5, 2008 12:06 AM (in response to frer)Hmmm...I just upgraded to versino 2.1.1.CR1 and my patch doesn't work anymore.
Is there anybody that uses any synchronous requests? This is essential for me and as I said before asynchronous is almost always correct but I have a few places where I would like to keep it synchronous.
Anybody been able to do it?
Any idea what I could do to activate this?
Thank you
-
3. Re: Synchronous @WebRemote call
luxspes Dec 5, 2008 12:40 AM (in response to frer)Do you realize that with synchronous calls from your javascript to a backend method you basically
hang
you browser until it gets a response... I can not imagine a case when a user could like that... -
4. Re: Synchronous @WebRemote call
frer Dec 5, 2008 3:34 PM (in response to frer)Yes I do understand it. I normally don't use it but in some cases I do not want the user to have the flexibility to do anything else...I want him to wait.
I know this is not a very popular design pattern and I myself do not encourage it. Prototype does allow it though because there are some practical uses for it.
Would it be possible to activate this for Seam?
-
5. Re: Synchronous @WebRemote call
luxspes Dec 5, 2008 8:33 PM (in response to frer)
Francois Eric wrote on Dec 05, 2008 15:34:
Yes I do understand it. I normally don't use it but in some cases I do not want the user to have the flexibility to do anything else...I want him to wait.
Make the user wait, and hanging the browser are very diffent things, if you want to make him wait, use a modal dialog saying:Please wait
(You can build it pretty easily by combining a4j:status with rich:modalPanel. It will automatically force the user to wait on ajax requests without hanging the browser.
I know this is not a very popular design pattern and I myself do not encourage it. Prototype does allow it though because there are some practical uses for it.
Practical uses for hanging the user browser? Can you give me an example?
Would it be possible to activate this for Seam?
I would consider it a bug if it were possible.