29 Oct 2010 1:05 AM #1
About async calls
I know this is more a GWT question, but I´ll appreciate any idea about this issue. Of course, I´ve posted this on GWT forums too.
I´m building a webapp which, depending on the user, will show some options on the menu or other ones. For doing this, I invoke a Single Singed On method passing as arguments, the user and the application and getting as return value a string identifying the "role" of the user. As I´m using GWT, I can´t invoke the SSO method from the client side, so I have to make a RPC to the server, which will invoke the method and return the "role" to the client.
I do all of this before "start creating the widgets that will be showed", but I face the problem of asyncronous calls.
I invoke the RPC, but the return value may come late (by late I mean when it has already started "building the widgets and appearance of the web application".
The only solution I see (and I don´t know if it´s correct or even possible) is start the building part in the body of "onSuccess(String result)" method, of the callback method associated to the RPC call.
I don´t know if I explanied it right...but I hope so.
29 Oct 2010 1:38 AM #2
Well, since you need to wait for the result of that method, returning the role, for building your UI, then yes, you need to build your ui just after the onsuccess returns.
You can do this by adding the ui building stuff in the onsucess method, or, by creating some kind of listener (which is more elegant).
29 Oct 2010 1:43 AM #3
First of all, thanks for ur answer
Where do you mean to create a listener? Sorry, but im new to this and I don´t get it all. Could you explain it a bit more? a small example?
29 Oct 2010 1:56 AM #4
I mean that, the class that build your ui, could be/have a listener.
A listener to the role string.
And, in case the role is retrieved by the class that gets the role, then it should fire an event for the roleListeners... notifying that the role was received.
But, anyway, that is just for elegance... probably, as for now, you could simply start building the ui in the onSuccess method...
By clavinovahan in forum Ext GWT: DiscussionReplies: 2Last Post: 2 Jun 2010, 1:19 AM
By jbraband in forum Ext 1.x: BugsReplies: 7Last Post: 21 Jan 2007, 5:57 PM
By techno_adi in forum Ext 1.x: Help & DiscussionReplies: 4Last Post: 6 Oct 2006, 3:37 AM