Re: [Help] GWT + GAE + Android - Where to start?

2014-02-20 Thread Bruno Brito
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 listDeviceInfo(
@Nullable @Named("cursor") String cursorString,
@Nullable @Named("limit") Integer limit) {

EntityManager mgr = null;
Cursor cursor = null;
List 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) 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. 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: "
+ 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 google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Help] GWT + GAE + Android - Where to start?

2014-02-15 Thread Andrew Mackenzie
Hi Bruno,
well you've made a lot of progress, so congratulations.

I think we need to overcome a basic misconception before going further

On the server side, you should only have ONE project, a combined GAE and
GWT project, not two.
No need to copy classes and files between projects, etc.
Just think about appengine being the application server that runs your GWT
(Javascript) web app.as if it was TomCat or some other app server.

The only difference over a "GAE only" project is that the GWT compiler will
generate JavaScript for you (from your Java code in your /client subfolders
for each GWT Module), and if you use GWT-RPCs, then you will have server
side code and should include the GWT jars (gwt-user.jar) to receive those
RPC requests and respond to them.

To "load" your GWT generated javascript you just need to add a normal

Re: [Help] GWT + GAE + Android - Where to start?

2014-02-14 Thread Bruno Brito
Andrew Mackenzie,

This is what I've acomplished so far:

- Created my entity class with JDO annotations.
- Created Endpoint class using GPE.
- Created Client Endpoint Libraries using GPE.
- Deployed to App Engine.
- Created an Android App, imported the necessary client libraries and I was 
able to do basic CRUD operations on my datastore.

GREAT!

Now comes the GWT part. Here's what I've done.
First, I used my backend project with the APIs, created a simple HTML file 
and used Google Cloud Endpoint support to Javascript to create and use some 
CRUD operations. Succeed.

My next step was to copy my endpoint classes and libraries to my GWT 
project and depploy it to my App Engine account.
I tested my Android App and had success with my crud operations.

But now comes the problem. I don't have access to my HTML file to make the 
CRUD. I had to insert the Javascript code directly to my Java code of GWT. 
And no matter what I tried, I simply didn't succeed.
Is there an easier way to do this? Because Google Cloud Endpoints supports 
Javascript client. I know GWT is basically JS, however, it doesn't sound 
that trivial to me.

Do you have any sample or tips?

Once again, thank you very much.

Em terça-feira, 11 de fevereiro de 2014 17h47min19s UTC-2, Andrew Mackenzie 
escreveu:
>
> No worries. I mean one server wepapp (GAE plus GWT) that exposes an API to 
> your Android app. You might want to chose JSON for API format and use gson 
> library in GAE and Android projects.
>
> The Google Cloud Platform Mobile Backends Starter Project might be a good 
> learning ground as it generates GAE and Android projects for you.
>
> See my post at
>
> http://devcon5.blogspot.com.es/2013/12/google-cloud-platform-mobile-backends.html
>
> If you structure by our code just right, you can have one Pure Java SHARED 
> project (eclipse, would be a module in IntelliJ or maven) that is used by 
> main Android app project and by GAE/GWT webapp project.but maybe not 
> worthy your effort. It can have common model objectsbut you might want 
> to JDO annotate on GAE and not on Android - that will break Android 
> compile :-(
>
> If you dont use Endpoints or some other library to help you create  REST 
> API then in your GAE project you will have to implement API using servlets 
> mapped to paths (in web.XML) that your Android client uses. 
>
>

-- 
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 google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Help] GWT + GAE + Android - Where to start?

2014-02-11 Thread Bruno Brito
Ok, I believe that now I understood a bit better.

I'll try to finish coding my GWT + GAE project, at least a simple version 
of it. And later on, I'll start the Android part.
I'll definetely come back and post many more questions.


For now, I'll take a look at the links you sent and do my homework on it 
all.

Thank you very much.

Em terça-feira, 11 de fevereiro de 2014 17h47min19s UTC-2, Andrew Mackenzie 
escreveu:
>
> No worries. I mean one server wepapp (GAE plus GWT) that exposes an API to 
> your Android app. You might want to chose JSON for API format and use gson 
> library in GAE and Android projects.
>
> The Google Cloud Platform Mobile Backends Starter Project might be a good 
> learning ground as it generates GAE and Android projects for you.
>
> See my post at
>
> http://devcon5.blogspot.com.es/2013/12/google-cloud-platform-mobile-backends.html
>
> If you structure by our code just right, you can have one Pure Java SHARED 
> project (eclipse, would be a module in IntelliJ or maven) that is used by 
> main Android app project and by GAE/GWT webapp project.but maybe not 
> worthy your effort. It can have common model objectsbut you might want 
> to JDO annotate on GAE and not on Android - that will break Android 
> compile :-(
>
> If you dont use Endpoints or some other library to help you create  REST 
> API then in your GAE project you will have to implement API using servlets 
> mapped to paths (in web.XML) that your Android client uses. 
>
>

-- 
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 google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Help] GWT + GAE + Android - Where to start?

2014-02-11 Thread Andrew Mackenzie
No worries. I mean one server wepapp (GAE plus GWT) that exposes an API to your 
Android app. You might want to chose JSON for API format and use gson library 
in GAE and Android projects.

The Google Cloud Platform Mobile Backends Starter Project might be a good 
learning ground as it generates GAE and Android projects for you.

See my post at
http://devcon5.blogspot.com.es/2013/12/google-cloud-platform-mobile-backends.html

If you structure by our code just right, you can have one Pure Java SHARED 
project (eclipse, would be a module in IntelliJ or maven) that is used by main 
Android app project and by GAE/GWT webapp project.but maybe not worthy your 
effort. It can have common model objectsbut you might want to JDO annotate 
on GAE and not on Android - that will break Android compile :-(

If you dont use Endpoints or some other library to help you create  REST API 
then in your GAE project you will have to implement API using servlets mapped 
to paths (in web.XML) that your Android client uses. 

-- 
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 google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Help] GWT + GAE + Android - Where to start?

2014-02-11 Thread Bruno Brito
Andrew Mackenzie,

Firstly, thank you very much for your answer.
I'm very new to using AppEngine and GWT, so I'm not very sure I understood 
everything. I still got a lot of homework to do.

I'm following a GWT + AppEngine tutorial and so far I'm able to create the 
web client and use the datastore with no problems.
Now, Google provides many ways to deploy a backend to GAE. Including now, 
they have a Mobile Backend Starter.

So, where do you think I should start from? GWT or Android? I got a bit 
confused when you said I should build one app with the server code and GWT 
generated JS combined. Did you mean a GWT app or Android one?
I'm sorry if my questions don't make much sense. But, I'm just starting 
working with it.

Once again, thank you very much.

Em terça-feira, 11 de fevereiro de 2014 16h56min14s UTC-2, Andrew Mackenzie 
escreveu:
>
> You just need to "layer" GWT on top of the GAE/J "servlet/jsp" application 
> by including web pages that load the JS generated by the GWT compiler.
>
> I.e. you build ONE app that does it all, with server code and GWT 
> generated JS all in one combined /war dir. You then debug locally on the 
> devserver or deploy to a GAE app id.
>
> You develop GWT modules with client/shared/server code. Server code must 
> be servlet code with no GWT calls. Shared code must be pure Java. Client 
> code uses GWT jars and using the .get.XML module description files get 
> compiled to JS in your /war Dir. Then load the generated "loader"  for the 
> JS code in an HTML file you put in /war also.
>
> There are GWT sample projects on App Engine you can follow.
>
> I have tried using the GWT RPCs from Android code and it works but is 
> tricky and unduly couples your API for the mobile app to GWT. So I suggest 
> you develop a core set of server API calls that you can call from (thin) 
> GWT RPC services and an XML/JSON API you expose to your mobile apps (if you 
> decide not to use endpoints).
>
> I will dig out a presentation I did on out experiences (SlideShare) and 
> post a linkbut you can find many tutorials and sample code.
>
>

-- 
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 google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Help] GWT + GAE + Android - Where to start?

2014-02-11 Thread Andrew Mackenzie
http://www.slideshare.net/andrew_d_mackenzie/google-dev-fest-presentation

-- 
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 google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Help] GWT + GAE + Android - Where to start?

2014-02-11 Thread Andrew Mackenzie
You just need to "layer" GWT on top of the GAE/J "servlet/jsp" application by 
including web pages that load the JS generated by the GWT compiler.

I.e. you build ONE app that does it all, with server code and GWT generated JS 
all in one combined /war dir. You then debug locally on the devserver or deploy 
to a GAE app id.

You develop GWT modules with client/shared/server code. Server code must be 
servlet code with no GWT calls. Shared code must be pure Java. Client code uses 
GWT jars and using the .get.XML module description files get compiled to JS in 
your /war Dir. Then load the generated "loader"  for the JS code in an HTML 
file you put in /war also.

There are GWT sample projects on App Engine you can follow.

I have tried using the GWT RPCs from Android code and it works but is tricky 
and unduly couples your API for the mobile app to GWT. So I suggest you develop 
a core set of server API calls that you can call from (thin) GWT RPC services 
and an XML/JSON API you expose to your mobile apps (if you decide not to use 
endpoints).

I will dig out a presentation I did on out experiences (SlideShare) and post a 
linkbut you can find many tutorials and sample code.

-- 
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 google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Help] GWT + GAE + Android - Where to start?

2014-02-11 Thread Bruno Brito
So, I found this video from Google I/O

http://www.google.com/events/io/2011/sessions/android-app-engine-a-developer-s-dream-combination.html

And that is basically what I needed. However, as I found out, Google Cloud 
Endpoints came to replace this Appengine Connected Android Project. And if 
I start one using the current GPE, I don`t have the same projects and 
classes.
Any tips on how to use Android and GWT as clients with Appengine as server?

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 google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.


[Help] GWT + GAE + Android - Where to start?

2014-02-11 Thread Bruno Brito
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/setup
 
in 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 google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.