Hi Bob, In my opinion, Click is the page centric framework.
When we need RESTful API in the Click based application, it will be called from HTML which is served by the page class. So It is natural these APIs are provided by the page class (using Page Actions in the current Click). If we really need a Service like you said, it might be better to use other frameworks specialized to providing RESTful API. I'm thinking about other way which takes advantage of features of Click. For example, to make single page apps using Click, we might be possible to provide Ajax based page navigation for existing page classes. But this is still an idea... 2013/4/27 Bob Schellink <[email protected]>: > 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 -- Naoki Takezoe
