Hi, Bob. What you're proposing sounds somewhat like an MVC style application in 
which the proposed Service class is the controller. Your code example reminds 
me of an ActionBean from the Stripes Web framework. I'm guessing this 
single-page application will be driven by Ajax. If that is the case, it is 
certainly possible to use ActionResults for XML/JSON requests. I can imagine 
subclasses (XMLResult, JSONResult) to conveniently convert business objects to 
the expected format. However, I would add an extra lifecycle method to the 
Service class, onDestroy(), to handle any necessary cleanup.

> Date: Sat, 27 Apr 2013 15:51:00 +0200
> From: [email protected]
> To: [email protected]
> Subject: Click Services
> 
> 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
                                          

Reply via email to