Hi Davis,

Yes, using GWT-RPC.  My problem was that I "forgot" that I'm dealing
with an asynchronous call.  I was trying to populate the field on my
form with data before the call had successfully returned.  So, I was
getting a Null Pointer Exception from the object I was fetching.  Once I
realized this, I moved my code to populate the field into the
onSuccess() method and it's all happy.

Thanks for the reply!
Dave


Davis Ford wrote:
> Are you using GWT-RPC? �I'm not sure I understand your problem
> completely. �
>
> So if I have a service like:
>
> public interface MyService extends RemoteService {
> �� public Entity fetchEntity(String id);
> }
>
> public interface MyServiceAsync {
> �� �void fetchEntity(String id, AsyncCallback<Entity> callback);
> }
>
> then, in the GWT code, something triggers the service. �Typically it
> is via a button click or some event. �You seem to indicate that you
> are doing it by passing the id as a URL parameter, like:
>
> http://host/my.gwt.application/Application.html?id=123
>
> You should be able to parse the URL using the
> Window.Location.getPath() to get the url param with a regex.
>
> Once you have that, you do this:
>
> MyServiceAsync service = GWT.create(MyService.class);
>
> service.fetchEntity(id, new AsyncCallback<Void>() {
> �� � onFailure(Throwable t) {
> �� � � � �Window.alert("service call failed: "+t.getMessage());
> �� � }
> �� � onSuccess(Entity e) {
> �� � � � // do something with the entity
> �� � }
> });
>
> After onSuccess( ) -- you populate the form with whatever. �
>
> On Mon, Nov 16, 2009 at 5:02 PM, David C. Hicks <[email protected]
> <mailto:[email protected]>> wrote:
>
>     I'm sure I must be making this harder than it needs to be, but I'm
>     having zero success doing it.
>
>     Entering a new form, I'd like to display the name of an entity
>     that was
>     selected on the the calling page. �The calling page is a Struts2
>     JSP, so
>     I don't have the entire entity. �I only have the entity's ID,
>     passed in
>     as a parameter on the request URL. �That's easy enough to get, and I
>     even have a service set up to go get the full entity once I have the
>     ID. �The problem is that the service is asyncronous. �So, I get a Null
>     Pointer Exception at the point where I try to set the data I'm
>     retrieving into a label because the call hasn't yet completed.
>
>     I'd rather not pass the name on the request URL - trying to avoid the
>     messy encoding/decoding problems. �I've tried to create an
>     AsyncCallback
>     class that included a hook that I could "wait" for, but this only
>     seemed
>     to create an infinite wait loop.
>
>     So, now I'm wondering if I need to somehow "bind" the retrieved
>     data to
>     a field on my form so that it will populate when the call completes.
>     Then again, maybe this is overkill, too.
>
>     Is there a better way to solve this problem?
>     Thanks,
>     Dave
>
>     --
>
>     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]
>     <mailto:[email protected]>.
>     To unsubscribe from this group, send email to
>     [email protected]
>     <mailto:google-web-toolkit%[email protected]>.
>     For more options, visit this group at
>     http://groups.google.com/group/google-web-toolkit?hl=.
>
>
>
>
>
> -- 
> Zeno Consulting, Inc.
> home: http://www.zenoconsulting.biz
> blog: http://zenoconsulting.wikidot.com
> p: 248.894.4922
> f: 313.884.2977
>
> --
>
> 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=.

--

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=.


Reply via email to