views:

885

answers:

3

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!

+1  A: 

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.

AlexJReid
A: 

AlexJReid: I would prefer to do as little processing on the client-side as possible. That is, all i want to do client-side is query the database for the results of the processing of the feeds that I ran server-side.

I used JSNI for the regular expressions because of documented discrepancies between the Java regex and javascripts capabilities to handle regex. At the time, I thought I wanted the processing to be done client-side, so I thought it was in my best interest to write it in javascript. Now that my plans have changed, would there be any reason to convert the regular expressions to java regex or will it work fine with server-side javascript regex? I'd like limit this project to java and javascript. from your response, i am judging that these two languages + gwt are all that I am going to need. Am i right to infer that?

Thank you very much!

culov
I don't think there are many reasons NOT to use the JS-regex, if you have put considerable effort into them and it would be painful to rewrite them to match Java regexp.One small comment: if you want to add something to a answer of a user, it's better to use the "comment" function (like I did now) instead of adding a new answer to the question, because this way your comment is connected with the answer you are commenting - and semantically, your comment is not an answer to your own question.
wilth
+1  A: 

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.

grigory
Yes, you should just be able to add one rpc service - a couple of interface definitions and a method implementation. You could use raw JDBC on the server side if the database work is simple enough, but if you start having to deal with relationships and writing a lot of CRUD code, switch to Hibernate or something similar.
Brian Deterling