• Post Reply Bookmark Topic Watch Topic
  • New Topic

Integrate RESTful web services with JSF2  RSS feed

 
Mat Anthony
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
has anybody come across any good examples of integrating a RESTful web service into a JSF2 web application.

Mat
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have, after a fashion.

I recently developed a RESTful server app by stealing one of my JSF webapps and plundering it. It stiff has JSF capabilities (I figured I might want a management UI), but so far I haven't done anything like that.

JSF is not a greedy system and can live in a webapp peacefully alongside REST and SOAP service frameworks. And even other UI frameworks such as Struts. When a JSF request is made, JSF handles it. When a REST request is made, the REST servlet handles it. The two systems can communicate internally using session and application scope objects, if they need to.
 
Mat Anthony
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim,
thanks for getting back to me.
I'm trying to build in the following into my jsf application:-
1)Expose RESTFul web services
2)Consume RESTFul web services
How do I expose my RESTFul web services within my JSF?. All the examples that I have seen use RESTFul web services URI to map to MVC controllers
and JSF2 uses beans. You indicate that a REST servlet will be able to handle requests and then you could could expose the result in a session or application object
that could be seen by JSF. Could I not intergate MVC controllers within my app? or is that not allowed. Still not sure how I can consume a RESTFUL service. Sorry Tim it's Friday and it's been a long week.
Can you please give me a bit more info.

Mat


 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Apache CXF as my REST controller. MVC isn't really an applicable term for REST, since REST is not really intended for GUI use.

The CXF servlet dispatches to REST handler objects where I can define (via annotation) the REST URL path component and map it to a corresponding method. That method can do whatever is necessary.

The app in question has Spring persistency objects injected into both JSF and REST beans as needed for my database services. To get the Session object, I have CXF inject a CXF Context object into my REST backing bean's base class and from there I can get the HttpServletRequest and thus the HttpSession object.
 
Mat Anthony
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the info Tim, sounds good.
I will give it a go.

Mat
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!