Problems loading data...

0 views
Skip to first unread message

Anti

unread,
Aug 12, 2008, 5:56:13 PM8/12/08
to Google Web Toolkit
Hi,

Thanks for your help.

I won´t go into details now, just the general idea as I am so confused
now that don´t know how to explain...

A class gets its data loaded using an
RPC...........................ok.
B class needs that data
too.................................................ok.
B class receives A as a parameter in its constructor..............ok.
B class receives the argument and keeps it locally................ok.
When trying to access the data in B class it is
null!!!!.............bad.

I made sure the data is present in A.

I was told something about the RPC call not making it on time...not
even sure if I know what that means.

Any comment is highly appreciated.

Bye!

Ian Petersen

unread,
Aug 12, 2008, 6:28:33 PM8/12/08
to Google-We...@googlegroups.com
You really haven't given enough information for me to be sure, but I'd
guess you're not taking into account the asynchronous nature of RPC.
If you need an A to construct a B and you're getting the A via RPC,
then you can't construct the B until the body of your AsyncCallback's
onSuccess method has been invoked.

If that doesn't help, you'd be well served by posting some code.

Ian

Richard Corsale

unread,
Aug 12, 2008, 11:59:10 PM8/12/08
to Google-We...@googlegroups.com
What are you using as a containers (class A and B)?

gregor

unread,
Aug 13, 2008, 5:26:33 AM8/13/08
to Google Web Toolkit
Hi Anti,

Sounds like you might be better off having A fire a change event
whenever its data is loaded or refreshed. B can be registered as a
listener with A and so be notified whenever it needs to update its own
view. If A fires its change event only after the RPC call has been
successfully returned and processed, B will only call for the new data
from A if when it is ready (i.e. the RPC call has actually returned) ,
and your null problem will go away.

RPC calls are asynchronous: that means that execution of your client
code does not stop to wait for an RPC call to return. So your client
is constructing B before the RPC call has returned and is calling A
for the data again before the RPC has returned. That's why you are
getting the error.

regards
gregor

Gabriel Zermeño

unread,
Aug 17, 2008, 7:26:07 PM8/17/08
to Google-We...@googlegroups.com
Thanks so much for helpful answers! Now I have a better idea of how PRC calls work.

Bye!
--
ggzr
Reply all
Reply to author
Forward
0 new messages