users@javaee-spec.java.net

[javaee-spec users] Re: [jsr342-experts] report on EG meeting at JavaOne

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Thu, 3 Oct 2013 17:34:26 -0700

I think there is some confusion about what JAX-RS MVC is about, so before we dive deep in that discussion, let me clarify what JAX-RS MVC means:

We DO NOT want to invent new MVC framework in JAX-RS. We merely want to expose API and SPI for integrating JAX-RS resources with existing MVC frameworks (JSF, JSP, FreeMarker, Moustache, ...). Essentially, we want to be able to send any response generated by a JAX-RS resource to a templating engine (or MVC framework, if you like) that can produce a views based on the response model JAX-RS resource provide and based on the template the templating framework will used to generate the ultimate HTTP response content. So, in a way it's similar to ASP.NET razor templates (http://weblogs.asp.net/scottgu/archive/2010/07/02/introducing-razor.aspx).

See here for more on what we already do in Jersey to support MVC templates:
https://jersey.java.net/documentation/2.3.1/mvc.html

Or check one of our examples that use Jersey MVC:
https://github.com/jersey/jersey/tree/master/examples/bookstore-webapp
https://github.com/jersey/jersey/tree/master/examples/freemarker-webapp
https://github.com/jersey/jersey/tree/master/examples/shortener-webapp

Thanks,
Marek

On Oct 3, 2013, at 5:32 AM, arjan tijms <arjan.tijms_at_gmail.com> wrote:

> On slide 19, "JAX-RS MVC"
>
> I agree with the central question "Do we really need another standard web framework?", and would like to specifically add the question "*Why* would we want a second web framework?"
>
> Is it because JSF is not popular enough, or are there specific use cases JSF can't address?
>
> As many of you may know, the web framework space is highly fragmented and fans of the many different frameworks can be very vocal. A few years ago Wicket saw a surge in popularity, but barely half a year later it was all about GWT, and then it was about Spring MVC, then Play! and then about "HTML5" and a slew of JavaScript based frameworks.
>
> Meanwhile there are proponents of both the component-oriented and action-oriented model. JSF being a prime representative of the component-oriented model got a lot of bad press in the beginning, which may have led to the idea that component-oriented frameworks were not ideal. But ever since JSF 2.0 there has been a massive reduction of complaints against JSF. Currently I often see JSF (and PrimeFaces) being recommended by users as reply on questions about which framework to use.
>
> Just a random example:
>
> User 1: "What are some good frameworks to get started with?"
>
> User 2: "I would go with JSF and PrimeFaces. This is a modern web development framework. There is still a lot of Spring MVC out there but a lot of it has become redundant to the standard JEE."
>
> (see http://www.reddit.com/r/java/comments/1nhf3f/how_to_begin_working_with_frameworks)
>
> So if a "JAX-RS MVC" is just to make Java EE more popular for web applications with the general public then that might not be entirely necessary any more.
>
> As for the technical merits of an action-oriented web framework we've seen that JSF has adopted some aspects of it lately. JSF 2.0 introduced view parameters and the preRenderView event, which allow users to implement some action-oriented like behaviour. JSF 2.2 further went into this direction with the introduction of view actions and the beginning of a stateless mode.
>
> I think it might not be too far removed from the current direction that JSF is going in to introduce a user supplied front controller that can be mapped to URL patterns via annotations just like JAX-RS. Such "delegate front controller" (i.e. called from the JSF supplied controller) could do pre-processing and select a view to be rendered. Today we can more or less do something like this via a combination of PrettyFaces, perhaps my experimental JavaVDL project, the new @Inject @Param of OmniFaces and the view actions in JSF 2.2. This can be really useful for handling an initial GET (non-faces) request and is currently the primary use case for which view parameters and view actions are used.
>
> Together with more elaborate support for stateless views in JSF 2.3, I wonder what specifics a new action-oriented framework could bring to the table that can't be easily realized in JSF.
>
> Personally I think that introducing a second competing web framework in Java EE would be really confusing to users. Microsoft does something like this (competing with its own APIs), e.g. mfc vs winforms vs wpf vs silverlight and I'm not really sure it makes things easier for developers. There's already a lot of different web frameworks to choose from in Java and Java EE itself offering yet another option will IMHO only fragment things even more.
>