I have a huge read-only RESTFUL application built in Spring MVC and Hibernate-Search that marshals some data to json and xml to be consumed for a mobile app and a monitoring application.
Our urls are pretty simple, we have this:
server:port/entity/id/?marshalling=json
or
server:port/entity/id/?marshalling=xml
and sometimes
server:port/entity/id/?marshalling=something&filterProp=entity.prop&ordering=desc
Now I have a requirement to make a presentation layer for this using JSF 2.1 and adding some user admin capabilities and I was thinking in something like this:
server:port/entity/id/?marshall=html
Or omitting entirely the marshall request parameter.
Now. As far as I know, you can only couple JSF 2.1 and Spring Web Flow, not Spring MVC directly. Anyone know how can I accomplish this requirement?
Both Spring MVC and JSF work on seperate servlets that can only be mapped to a context that doesn’t conflict with another servlet, so this cannot be done easily and if you succeed then it is basically an enormous hack.
If I absolutely had to do it this way (which I wouldn’t), then I would probably use the marshall servlet to clone my JSF requests, send that request to my FacesServlet using a WebClient, and then copying the returning WebClient response into my marshall servlet response and return that. This would be transparent to the user but highly messy and potentially insecure.
The best way to implement a seperate web based presentation layer would be for requests to your presentation layer to be mapped to the FacesServlet so that your RESTFUL web services do not get called directly.
Actor – > /admin/page.jsf -> FacesServlet -> JSF View – >
JSF Controller -> Business Logic Layer -> RESTFUL Web Services
In this way your RESTFUL web services can return XML or JSON data and act as your DAO, your Business Logic layer can perform additional logic on that.