I'm using Windows 7 Eclipse Juno with the latest Google App Engine plugin.
I'm trying to write a program to check I understand how to store things in the Google App Engine datastore and also how to use GWT RPC.
The program has 2 text boxes for entering a name and address.
See the following image.
The name and address values are placed in a object called ContactDetails which is kept in the shared directory.
They are passed to to the datastore using GWT RPC and placed in a Entity kind called storedcontact.
The image below shows my directory structure.
The Image below shows the values getting stored in the development datastore.
Once in the datastore the I retrieve all the names and addresses from the datastore
Then I return them back to client side via the GWT RPC and display them in a flex table as shown below
The problem is it works a couple of times and then it fails.
I put in some system.out.println statements in an effort to diagnose the problem.
Below is the console display:
I can't understand why it will work twice and then fail?
below is my code.
Thank you Manesh Godbole for replying to my problem.
If you look at the code for RpcServiceImpl.storeContact method line 39 you will see that I have already printed the array size to the console
Each time I enter a new set of values the array is incremented to a larger size as you can see in the stack trace lines 12, 15, and 19
I have repeated the what I have sent to the console below
Note that in the last name and address I entered is Phil Mitchell 7 Albert Square
He appears to be in the datastore and the array is set for 3 entitys
So why is he not in the result? This is the problem
The following 3 lines give me the array size and display the array size to the console. These three lines appear to be working
Why is Phil Mitchell in the datastore and is counted as in the datastore, but the for loop cannot find him?
Try switching over to ArrayList<ContactDetails> instead, it appears the source you are getting your count from is not giving you the real number of records perhaps? With an ArrayList, you just use #add(member) as needed, and you don't have to worry about adding past end of array.
posted 7 years ago
Thank you Micheal Joyner for your reply my program now works.
I had to make a few additional changes to the Rpc return types.
I have shown the new code below.
The addToTable method also needed changing too as shown below