culov
culov

Reputation: 11

GWT server-side interaction with database

I am building a project in GWT that pulls an rss feed, executes regular expressions on the feed (in javascript using JSNI), and then stores that resulting data on a database where the users can access it.

As of right now, I have been writing all the code in the client-side .java file hoping that I could simply transfer it to the server-side. How do I go about moving part of the code to the server-side of the project? The code I have now is too bulky to be run on the client-side so id like to run it server-side and store the results in a database. Is it advisable to write the server-side code using GWT or should that be done with some other framework or maybe PHP? I would ideally like to develop the entire project with GWT since it has worked really well for me up to this point.

I have also been having trouble finding the resources that I need to connect to the database and update it, server-side from GWT. Can I do this with Hibernate?

Thank you very much!

Upvotes: 1

Views: 3753

Answers (2)

topchef
topchef

Reputation: 19783

If it runs in GWT then it runs in Java (almost): if it is not concerned with widgets or JavaScript directly (via JSNI). Obviously, you want no code that deals with widgets or JSNI on a server anyway.

So go ahead and move it.

To communicate you would use GWT-RPC - your server code simply runs as a servlet with all the power Java servlets offer, including ability to use Hibernate, other Java frameworks. Your server code stays as part of GWT application but doesn't get neither translated to JavaScript nor deployed on a client.

Single best resource on architecture of GWT apps is here.

Upvotes: 1

AlexJReid
AlexJReid

Reputation: 1601

Sounds to me like you could run the whole thing on the server side and not use GWT.

If you do want to do your processing on the client, you'll need to submit the results to a server over HTTP, probably as text.

You could do this with GWT RPC, an HTTP request using RequestBuilder or finally use a FormPanel containing a hidden field. GWT RPC means you have to write your serverside code in Java. The other two approaches could be any platform that speaks HTTP: PHP, Python, .NET ...

NB: JSNI is powerful but it could be argued that you are throwing away the power of GWT - that is, the ability to write client-side code in Java.

Upvotes: 2

Related Questions