문제

I would like to use RESTful services in a CDI/JSF2 application. I am not very familiar with JAX-RS however I have read that its lifecycle does not play well with CDI/JSF2. Is it possible to incorporate JAX-RS with CDI/JSF2 in a JEE6 stack? If not are there alternatives?

thanks

도움이 되었습니까?

해결책

You can use JAX-RS just fine along side a JSF application, however, they don't play well together. For instance, you can't use JAX-RS to have "http://localhost:8080/story/92/" return a JSF page with a Story entity with ID 92.

You can, however, use PrettyFaces to do something very similar to this.

JAX-RS makes sense for non-JSF resources. "http://localhost:8080/story.xml" makes perfect sense for JAX-RS.

다른 팁

You can call your rest services from your JSF templates. For example you can run your rest services from http://localhost:8080/services/ while your JSF page is returned on http://localhost:8080/index.xhtml. You can then write some custom javascript to call your rest services from your JSF page. This is actually the general practice with REST services so they can be consumed by many different UIs. JSF may not be the best for consuming REST services, but it is possible.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top