Hello everybody,
I've been making a lot of progress in my project, however, once again I
faced many problems.
When I chose to use GWT, I didn't think that I would have so much trouble
facing Javascript codes.
Just to be clear, I'm using Google Cloud Endpoints APIs + GWT, and as you
know, Google Endpoints API access is made via Javascript.
So, here is my problem.
I have an API that should retrieve a list of objects. Example of code:
@ApiMethod(name = "listDeviceInfo")
public CollectionResponse<DeviceInfo> listDeviceInfo(
@Nullable @Named("cursor") String cursorString,
@Nullable @Named("limit") Integer limit) {
EntityManager mgr = null;
Cursor cursor = null;
List<DeviceInfo> execute = null;
try {
mgr = getEntityManager();
Query query = mgr
.createQuery("select from DeviceInfo as DeviceInfo");
if (cursorString != null && cursorString != "") {
cursor = Cursor.fromWebSafeString(cursorString);
query.setHint(JPACursorHelper.CURSOR_HINT, cursor);
}
if (limit != null) {
query.setFirstResult(0);
query.setMaxResults(limit);
}
execute = (List<DeviceInfo>) query.getResultList();
cursor = JPACursorHelper.getCursor(execute);
if (cursor != null)
cursorString = cursor.toWebSafeString();
// Tight loop for fetching all entities from datastore and accomodate
// for lazy fetch.
for (DeviceInfo obj : execute)
;
} finally {
mgr.close();
}
return CollectionResponse.<DeviceInfo> builder().setItems(execute)
.setNextPageToken(cursorString).build();
}
But how do I access this API through Javascript?
Well, with a little help from a Google API, I can simply call:
gapi.client.deviceinfoendpoint
.listDeviceInfo()
.execute(
function(deviceInfoItems, deviceInfoItemsRaw) {
errorResult = checkErrorResponse(deviceInfoItems,
deviceInfoItemsRaw);
if (errorResult.isError) {
showError("There was a problem contacting the server when
attempting to list the registered devices. "
+ "Please refresh the page and try again in a short
while. Here's the error information:<br/> "
+ errorResult.errorMessage);
} else {
//Do something with deviceInfoItems.items
}
});
I know how to call this javascript function inside my GWT code using a
native method. However, I want to create a List of DeviceInfo objects with
the results of this Query inside my GWT Java code, and then I'll be able to
manipulate them into a Flex or Grid.
Is that even possible? How could I do that?
I appreciate any help.
Best Regards.
Em segunda-feira, 10 de fevereiro de 2014 22h31min23s UTC-2, Bruno Brito
escreveu:
>
> Hey guys, this is my first post here, so I'm sorry if I'm not clear enough
> about my question.
>
> Well, basically what I want to do is:
> - Create a website using GWT and deploy it to App Engine in order to use
> the datastore. I've already done it, nothing wrong about it.
> - The second part of this project is about building an Android App which
> can access the same datastore that I use for my GWT project. Read the
> entities and retrieve them to display on the screen. And also use Google
> Cloud Messaging.
>
>
> The problems are:
> - I've noticed that there is Google Mobile Backend Starter which already
> deploys a backend to AppEngine and allows Cloud Messaging and many other
> features. But, how would I link GWT to this same application at GAE? If I
> deploy my GWT project, I lose the Android one.
> - I was also following this guide here:
> https://developers.google.com/appengine/docs/java/endpoints/getstarted/backend/setupin
> order to create my own backend, deploy it to AppEngine and then use the
> client endpoints with Javascript. However, if I do this, I can't deploy my
> GWT website to this app engine application.
>
> I don't know if I was clear enough. I've searched the group and saw some
> posts similar to my question, but none was very clear about it.
>
> I'll be glad if anyone can help.
>
> Thanks!
>
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.