Re: RPC Issues - Lifespan of Data from a RPC

2009-05-17 Thread Salvador Diaz

> I was wondering if anyone knows of a way to run a function after the
> RPC is complete.

The completion of a RPC call is signaled by the call to the onSuccess
method of the asyncCallback you pass to the RPC as the last argument.
So how does this answer your question ? Let's take a concrete example.
Let's say you call your rpc in the following way:


myRPCAsyncInstance.myMethodCall(parameter1, parameter2, ...,
parameterN, myCallback);


This is how you would implement your callback to call a method call
doSomethingWhenRpcIsFinished:


AsyncCallback myCallback = new
AsyncCallback(){
  //This is the method called when the RPC call failed
  public void onFailure(Throwable t){
GWT.log("RPC failed");
  }

  //This is the method called when the RPC finished successfully
  public void onSuccess(MyReturnObject result){
doSomethingWhenRpcIsFinished();
  }
};


Hope that helps,

Salvador

On May 15, 10:52 pm, JohnofLong  wrote:
> Thank you for your input, what was happening is once the RPC was
> complete the data that I was adding to the ArrayList would disappear.
> So I decided to do something ugly, but it works. I am writing the data
> onto a invisible div on the page then getting it then adding it to the
> ArrayList. It seems to work just fine.
>
> I am new to GWT but I am starting to get a basic understanding on how
> these things work.
>
> I was wondering if anyone knows of a way to run a function after the
> RPC is complete.
>
> Thanks!
>
> John
>
> On May 9, 7:44 am, Salvador Diaz  wrote:
>
> > Well, the indexOutOfBoundsException can't possibly be thrown by the
> > method add of an ArrayList (that's the type of productArrayList, isn't
> > it?). In fact there's nothing in your snippets that'll throw that
> > exception. Did you debug the method call on the server side ?
> > Somewhere in your Eclipse or HostedMode console you'll have a complete
> > stack trace that'll tell you the exact line of code that's throwing
> > that exception. I suggest you read it carefully.
>
> > As for the lifecycle of your RPCs, it is the normal lifecycle of a
> > servlet.
>
> > Hope that helps,
>
> > Salvador
>
> > On May 8, 10:46 pm, JohnofLong  wrote:
>
> > > I tried to find this topic already on the discussions but could not
> > > find it.
>
> > > Currently using  GWT 1.5.3
>
> > > I am making a RPC to call to read XML and call a function that loads
> > > the data into an ArrayList of classes. I have made a class that
> > > implements RequestCallback(LoadData) and takes in my mainClass
> > > example:
>
> > > LoadData loadData = new LoadData(this);
> > >                 String url = xmlString;
> > >             RequestBuilder requestBuilder = new RequestBuilder
> > > (RequestBuilder.GET, url);
> > >             try {
> > >               requestBuilder.sendRequest(null, loadData);
> > >             } catch (RequestException ex) {
> > >                 //Window.alert("exception");
> > >             }
>
> > > Inside the RPC class:
>
> > > mainClass.addProducts(id, sku, name, catagory) ;
>
> > > inside my main class:
> > > public addProducts(int id, int sku, String name, String catagory) {
> > >         productArrayList.add(new product(id, sku, name, catagory);
>
> > > }
>
> > > But when I call a method on my productArray it just says index out of
> > > bound (basically the arrayList is empty) but I know it is calling the
> > > addProduct method
>
> > > I am guessing the lifespan of the data is tied to the lifespan of the
> > > RPC call.
>
> > > What sort of things can I do to get around this(assuming my
> > > assumptions are correct)?
>
> > > I greatly appreciate the help and apologize if this topic is covered
> > > somewhere already.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---



Re: RPC Issues - Lifespan of Data from a RPC

2009-05-15 Thread JohnofLong

Thank you for your input, what was happening is once the RPC was
complete the data that I was adding to the ArrayList would disappear.
So I decided to do something ugly, but it works. I am writing the data
onto a invisible div on the page then getting it then adding it to the
ArrayList. It seems to work just fine.

I am new to GWT but I am starting to get a basic understanding on how
these things work.

I was wondering if anyone knows of a way to run a function after the
RPC is complete.

Thanks!

John

On May 9, 7:44 am, Salvador Diaz  wrote:
> Well, the indexOutOfBoundsException can't possibly be thrown by the
> method add of an ArrayList (that's the type of productArrayList, isn't
> it?). In fact there's nothing in your snippets that'll throw that
> exception. Did you debug the method call on the server side ?
> Somewhere in your Eclipse or HostedMode console you'll have a complete
> stack trace that'll tell you the exact line of code that's throwing
> that exception. I suggest you read it carefully.
>
> As for the lifecycle of your RPCs, it is the normal lifecycle of a
> servlet.
>
> Hope that helps,
>
> Salvador
>
> On May 8, 10:46 pm, JohnofLong  wrote:
>
> > I tried to find this topic already on the discussions but could not
> > find it.
>
> > Currently using  GWT 1.5.3
>
> > I am making a RPC to call to read XML and call a function that loads
> > the data into an ArrayList of classes. I have made a class that
> > implements RequestCallback(LoadData) and takes in my mainClass
> > example:
>
> > LoadData loadData = new LoadData(this);
> >                 String url = xmlString;
> >             RequestBuilder requestBuilder = new RequestBuilder
> > (RequestBuilder.GET, url);
> >             try {
> >               requestBuilder.sendRequest(null, loadData);
> >             } catch (RequestException ex) {
> >                 //Window.alert("exception");
> >             }
>
> > Inside the RPC class:
>
> > mainClass.addProducts(id, sku, name, catagory) ;
>
> > inside my main class:
> > public addProducts(int id, int sku, String name, String catagory) {
> >         productArrayList.add(new product(id, sku, name, catagory);
>
> > }
>
> > But when I call a method on my productArray it just says index out of
> > bound (basically the arrayList is empty) but I know it is calling the
> > addProduct method
>
> > I am guessing the lifespan of the data is tied to the lifespan of the
> > RPC call.
>
> > What sort of things can I do to get around this(assuming my
> > assumptions are correct)?
>
> > I greatly appreciate the help and apologize if this topic is covered
> > somewhere already.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---



Re: RPC Issues - Lifespan of Data from a RPC

2009-05-09 Thread Salvador Diaz

Well, the indexOutOfBoundsException can't possibly be thrown by the
method add of an ArrayList (that's the type of productArrayList, isn't
it?). In fact there's nothing in your snippets that'll throw that
exception. Did you debug the method call on the server side ?
Somewhere in your Eclipse or HostedMode console you'll have a complete
stack trace that'll tell you the exact line of code that's throwing
that exception. I suggest you read it carefully.

As for the lifecycle of your RPCs, it is the normal lifecycle of a
servlet.

Hope that helps,

Salvador

On May 8, 10:46 pm, JohnofLong  wrote:
> I tried to find this topic already on the discussions but could not
> find it.
>
> Currently using  GWT 1.5.3
>
> I am making a RPC to call to read XML and call a function that loads
> the data into an ArrayList of classes. I have made a class that
> implements RequestCallback(LoadData) and takes in my mainClass
> example:
>
> LoadData loadData = new LoadData(this);
>                 String url = xmlString;
>             RequestBuilder requestBuilder = new RequestBuilder
> (RequestBuilder.GET, url);
>             try {
>               requestBuilder.sendRequest(null, loadData);
>             } catch (RequestException ex) {
>                 //Window.alert("exception");
>             }
>
> Inside the RPC class:
>
> mainClass.addProducts(id, sku, name, catagory) ;
>
> inside my main class:
> public addProducts(int id, int sku, String name, String catagory) {
>         productArrayList.add(new product(id, sku, name, catagory);
>
> }
>
> But when I call a method on my productArray it just says index out of
> bound (basically the arrayList is empty) but I know it is calling the
> addProduct method
>
> I am guessing the lifespan of the data is tied to the lifespan of the
> RPC call.
>
> What sort of things can I do to get around this(assuming my
> assumptions are correct)?
>
> I greatly appreciate the help and apologize if this topic is covered
> somewhere already.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---



Re: RPC Issues - Lifespan of Data from a RPC

2009-05-08 Thread Paul Grenyer
You're right. You could use spring or persist you data to a file or database 
between calls.

Sent from my BlackBerry® wireless device

-Original Message-
From: JohnofLong 

Date: Fri, 8 May 2009 13:46:01 
To: Google Web Toolkit
Subject: RPC Issues - Lifespan of Data from a RPC



I tried to find this topic already on the discussions but could not
find it.

Currently using  GWT 1.5.3

I am making a RPC to call to read XML and call a function that loads
the data into an ArrayList of classes. I have made a class that
implements RequestCallback(LoadData) and takes in my mainClass
example:

LoadData loadData = new LoadData(this);
String url = xmlString;
RequestBuilder requestBuilder = new RequestBuilder
(RequestBuilder.GET, url);
try {
  requestBuilder.sendRequest(null, loadData);
} catch (RequestException ex) {
//Window.alert("exception");
}

Inside the RPC class:

mainClass.addProducts(id, sku, name, catagory) ;

inside my main class:
public addProducts(int id, int sku, String name, String catagory) {
productArrayList.add(new product(id, sku, name, catagory);
}

But when I call a method on my productArray it just says index out of
bound (basically the arrayList is empty) but I know it is calling the
addProduct method

I am guessing the lifespan of the data is tied to the lifespan of the
RPC call.

What sort of things can I do to get around this(assuming my
assumptions are correct)?

I greatly appreciate the help and apologize if this topic is covered
somewhere already.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---



RPC Issues - Lifespan of Data from a RPC

2009-05-08 Thread JohnofLong

I tried to find this topic already on the discussions but could not
find it.

Currently using  GWT 1.5.3

I am making a RPC to call to read XML and call a function that loads
the data into an ArrayList of classes. I have made a class that
implements RequestCallback(LoadData) and takes in my mainClass
example:

LoadData loadData = new LoadData(this);
String url = xmlString;
RequestBuilder requestBuilder = new RequestBuilder
(RequestBuilder.GET, url);
try {
  requestBuilder.sendRequest(null, loadData);
} catch (RequestException ex) {
//Window.alert("exception");
}

Inside the RPC class:

mainClass.addProducts(id, sku, name, catagory) ;

inside my main class:
public addProducts(int id, int sku, String name, String catagory) {
productArrayList.add(new product(id, sku, name, catagory);
}

But when I call a method on my productArray it just says index out of
bound (basically the arrayList is empty) but I know it is calling the
addProduct method

I am guessing the lifespan of the data is tied to the lifespan of the
RPC call.

What sort of things can I do to get around this(assuming my
assumptions are correct)?

I greatly appreciate the help and apologize if this topic is covered
somewhere already.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---