Hi Bob,
i like the Service idea very much.
Having played with jQuery for a while,i always get in the need to
have the data on the client side in JSON format, while usually they are
modeled as POJO on the server side.
I found this project from Google which does the job of generating JSON
from POJOs.
http://code.google.com/p/google-gson/
worked very well form my case .
Marco
Il 27/04/2013 15:51, Bob Schellink ha scritto:
Hi all,
With HTML5 a new breed of applications have become common, the so
called single-page apps, where the client side is written entirely in
Javascript using jQuery, Dojo, Mootools etc. The server is used to
fetch data, through JSON.
GWT is a possible choice for Java devs, however using Java for heavy
client side apps is a little clunky. Google also seems to have
abandoned GWT and moved resources to Dart.
Click is mostly concerned with responding to requests with HTML code
so it isn't a good fit for these single-page apps.
Most of these single-page apps use Rest frameworks as the backend.
I've been wondering if it is worth adding a Service concept to Click
that can be used to serve up JSON/XML etc to single-page apps. The
Service would be a first class citizen similar to Page, but only with
the onInit lifecycle method. Other public methods is for handling the
request eg:
class MyService {
public void onInit() {
// Only lifecycle method?
}
public ActionResult getPersonData() {
}
public ActionResult savePersonData() {
}
}
I'm not thinking of a Rest based architecture here, simply a JSON/XML
over HTTP service layer.
ClickServlet might also have to be refactored into a Filter for more
flexible URL mappings.
On the other hand this might just be reinventing the wheel. One thing
which would be nice with Click (compared to the other Rest frameworks)
is our integration with Velocity.
Thoughts?
Kind regards
Bob