hi Thomas, Thanks a bunch, that idea really works for me. Awesome. Kudos. Hey Deepak, I have not yet worked on RequestBuilder - but after seeing the javadoc, with very little knowledge, I am guessing this might be what you are looking for - you need to write the code here - RequestBuilder's setCallback(RequestCallback callback) - in RequestCallback object, use onResponseReceived(Request request, Response response) method to make sure that you access the singleton class from this method.
Hope this helps. Thanks, Vikky! On Aug 19, 9:35 pm, Thomas Dvornik <[email protected]> wrote: > Hey Vikky, > > You may be right that it's not possible in GWT. It would actually make > sense that you get two different instantiations. > > If both the server and the client had the same instance, you could > technically change something on the server, and see it on the client > without sending it back, which is not possible. Plus, there is a bunch > of other problems with the server and client sharing a singleton: > serialization, java/javascript, etc. I could be wrong. > > I would recommend sending the data back to the client, then in the > onSuccess method, write all the data to a singleton class on the > client side. > > Another option would be to imitate a singleton class on the client. > Have a class, where every time you access the instantiation or fields, > it gets it from the server singleton via RPC. > > Hope that helps, > > Tom > > On Aug 18, 10:54 pm, Deepak Singh <[email protected]> wrote: > > > Hi > > > Hi Vikky, > > > I also face one similar problem. > > I have done cross-domain call using RequestBuilder in client package. My > > problem is how to make sure to access the data only after the request > > callback has completed. I have both the RequestBuilder class and the class > > accessing the data of callback in client package itself. Any suggestion how > > you have done this. > > > Reagrds > > Deepak > > > On Thu, Aug 19, 2010 at 11:11 AM, vikky8118 <[email protected]> wrote: > > > Hi Thomas, thank you very much for your reply. > > > > I have made sure that client code is trying to access only after the > > > service has populated data into the single-ton class. I am trying to > > > access data from client in the onSuccess method AsyncCallback class of > > > the service which does the actual storing the data into the shared > > > single-ton class. > > > > After examining the trace/logs, I see that the object returned by the > > > getinstance() when called from service is different from the one we > > > get when client code is calling getinstance(). > > > > After little investigation, I am just wondering, what I am trying to > > > do is possible or not in GWT. I know that GWT's shared package can > > > contain code, which will be translated to javascript and included in > > > client side, and kept as java and included in server side. But, what > > > about data? Once after the application is loaded, how come the server > > > side code can update the javascript code in client? Is it possible > > > in first place? If yes, what am I missing? > > > > Hope, I am clear in my description above. Let me know, if you need any > > > more info from my side. Thanks again for your response and your help > > > is much appreciated. > > > > Cheers, > > > Vikky > > > > On Aug 19, 1:02 am, Thomas Dvornik <[email protected]> wrote: > > > > Some code will be useful, especially the singleton class. > > > > > Also, when/how are you getting the data? One potential problem I can > > > > see happening is the client code accessing the data before the server > > > > sets the values in the singleton class. > > > > > Tom > > > > > On Aug 18, 2:24 am, vikky8118 <[email protected]> wrote: > > > > > > Hello all, I am new to GWT programming! Here is the problem that I am > > > > > trying to solve since two days. > > > > > > I have the following > > > > > service package : a server side service which interacts with db and > > > > > gets data and stores the data in the shared package class > > > > > shared package : a shared class which represent the data I wanted > > > > > to store. it has setters and getters to all the class fields. This is > > > > > a single ton class. > > > > > client package : a client side class which invokes the server > > > > > side service and then tries to access the data from shared class in > > > > > which, we have data which is populated by server side service. > > > > > > But, this is what happening. > > > > > > Service is being called successfully and service side operations are > > > > > performed successfully and shared class data is populated properly. > > > > > But, when I try to get the shared package - single ton class, I get a > > > > > different object / not the one I wanted and I get junk data from the > > > > > getters of the class ( 'undefined' ) > > > > > > I am not sure if this is the right way, but, the data is frequently > > > > > accessed. Hence, my plan is to access the data from db for once, store > > > > > it in shared package single ton class and access it every time from it > > > > > when ever client needs it. > > > > > > Can some one help me, what flaw I am making here? > > > > > > Thanks in advance. > > > > > Vikky. > > > > -- > > > You received this message because you are subscribed to the Google Groups > > > "Google Web Toolkit" group. > > > To post to this group, send email to [email protected]. > > > To unsubscribe from this group, send email to > > > [email protected]<google-web-toolkit%2Bunsubs > > > [email protected]> > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/google-web-toolkit?hl=en. -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
