Sergey, Perfect solutions! Thanks again.
Guy Sent from my iPad On 05 Feb 2012, at 20:35, Sergey Beryozkin <sberyoz...@gmail.com> wrote: > Hi Guy > On 04/02/12 09:46, Guy Pardon wrote: >> Sergey, >> >> Looks very cool, thanks! I suppose validation errors can be handled via the >> Response.sendOther redirection, with error beans as request attributes? >> > > This is what I did in the demo...Say we have a class such as > > @Path("/service") > public class RootResource { > @GET > @Path("get") > public Response get() { > if (allIsOK) { > // return SomeResponse, RequestDispatcherProvider will make it available to > SomeResponse view handler > return Response.ok().entity(SomeResponse).build(); > } else { > return Response.seeOther("validationError").build(); > } > } > > @GET > @Path("validationError") > public ValidationResponse validationError() { > // return ValidationResponse, RequestDispatcherProvider will make it > available to the validation error view handler > } > > } > > > Response.seeOther in get() will get the client redirected to the validation > error handler, there needs be some association available between requests. > Ex, in my case the Response.seeOther() sets the error code as a query > parameter... > > The simpler option is simply have get() above return the usual Response, with > the entity set to either SomeResponse or ValidationErrror, without any > Response.seeOther and configure > RequestDispatcherProvider to redirect to say SomeResponse.jsp if the entity > is SomeResponse and to ValidationError.jsp in other cases... > > Yet one more option is to return some CompositeResponse with the > CompositeResponse.jsp handler delegating further based on whether > CompositeResponse has the 'good' data or not... > Do you think one of the above options will work for you ? > > Cheers, Sergey > > >> Guy >> >> On 3-feb-2012, at 23:11, Sergey Beryozkin wrote: >> >> Hi Guy >> On 03/02/12 18:27, Guy Pardon wrote: >>> Hi, >>> >>> Thanks for answering! >>> >>> The REST/JAXRS paradigm offers a basic controller mechanism, and I can >>> return text/html (and other media types) as well as forward to JSP pages. >>> >>> I've always disliked struts and JSF and am trying to push JAXRS to the >>> limits - hence my question :-) >>> >> >> Try this then: >> http://cxf.apache.org/docs/jax-rs-redirection.html >> :-) >> >> Cheers, Sergey >> >>> Guy >>> >>> On 3-feb-2012, at 19:13, KARR, DAVID wrote: >>> >>>> -----Original Message----- >>>> From: Guy Pardon [mailto:g...@atomikos.com] >>>> Sent: Friday, February 03, 2012 9:54 AM >>>> To: users@cxf.apache.org >>>> Subject: REST and MVC for webapps >>>> >>>> Hi, >>>> >>>> I am looking for examples and/or information on using CXF/REST/JAXRS as >>>> the controller for html webapps - instead of Struts or JSF. >>>> >>>> Any pointers available? >>> >>> Just a high-level comment on the approach: >>> >>> If you're building a "conventional" web site where you move from page to >>> page, a REST service would likely only represent a portion of your >>> application. You'd still want to have a "conventional" web framework like >>> Spring MVC, Struts, or JSF (which provides some additional paradigms). >>> >>> If, however, you're building a "single-page web application" where server >>> communication is primarily done through AJAX calls from a Javascript >>> framework like Dojo or others, then a REST service might become more >>> prominent. >>> >>> The point is that a REST service handles a certain kind of interaction >>> pattern, and page to page navigation doesn't quite fit that. >>> >> >> > > > -- > Sergey Beryozkin > > Talend Community Coders > http://coders.talend.com/ > > Blog: http://sberyozkin.blogspot.com